Skip to content

Commit

Permalink
Add package_with_files factory
Browse files Browse the repository at this point in the history
Which creates a package with three files:
  - README.txt
  - <name>.spec
  - <name>.changes
  • Loading branch information
saraycp committed Jan 23, 2023
1 parent 9aa4f90 commit 704578c
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/api/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ AllCops:
- 'app/jobs/old/consistency_check_job.rb'
# Binaries are generated, so we don't lint them
- 'bin/**/*'
- 'spec/fixtures/files/factory_package.spec'
SuggestExtensions:
# We don't want extra cops for minitest since we want to migrate those tests to RSpec
rubocop-minitest: false
Expand Down
28 changes: 28 additions & 0 deletions src/api/spec/factories/packages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,34 @@
end
end

# Creates a package with three files: README.txt, <name>.spec and <name>.changes.
factory :package_with_files do
transient do
file_name { 'README.txt' }
file_content { Faker::Lorem.paragraph }
spec_file_name { "#{name}.spec" }
spec_file_content { Pathname.new(File.join('spec', 'fixtures', 'files', 'factory_package.spec')).read.gsub('factory_package', name) }
changes_file_content { Pathname.new(File.join('spec', 'fixtures', 'files', 'factory_package.changes')).read }
changes_file_name { "#{name}.changes" }
end

after(:create) do |package, evaluator|
# NOTE: Enable global write through when writing new VCR cassetes.
# ensure the backend knows the project
if CONFIG['global_write_through']
Backend::Connection.put(
"/source/#{CGI.escape(package.project.name)}/#{CGI.escape(package.name)}/#{evaluator.file_name}", evaluator.file_content
)
Backend::Connection.put(
"/source/#{CGI.escape(package.project.name)}/#{CGI.escape(package.name)}/#{evaluator.spec_file_name}", evaluator.spec_file_content
)
Backend::Connection.put(
"/source/#{CGI.escape(package.project.name)}/#{CGI.escape(package.name)}/#{evaluator.changes_file_name}", evaluator.changes_file_content
)
end
end
end

factory :package_with_changes_file do
transient do
changes_file_content { Pathname.new(File.join('spec', 'fixtures', 'files', 'factory_package.changes')).read }
Expand Down
1 change: 1 addition & 0 deletions src/api/spec/fixtures/files/factory_package.changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Fri Aug 11 16:58:15 UTC 2017 - tom@opensuse.org

- Testing the submit diff
- Fixing issues boo#1111111 and CVE-2011-1111 among others.

-------------------------------------------------------------------
Wed Aug 2 14:59:15 UTC 2017 - iggy@opensuse.org
Expand Down
27 changes: 27 additions & 0 deletions src/api/spec/fixtures/files/factory_package.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Name: factory_package
Version: 1
Release: 1
Summary: Most simple RPM package
License: CC0-1.0

%description
This is my first RPM package, which does nothing.

%prep
# we have no source, so nothing here

%build
cat > factory_package.sh <<EOF
#!/usr/bin/bash
echo Hello world, from factory_package.
EOF

%install
mkdir -p %{buildroot}/usr/bin/
install -m 755 factory_package.sh %{buildroot}/usr/bin/factory_package.sh

%files
/usr/bin/factory_package.sh

%changelog
# let skip this for now

0 comments on commit 704578c

Please sign in to comment.