From 4aaa023391aa16c3c0c680bd298761b3b1879fd6 Mon Sep 17 00:00:00 2001 From: Victor Pereira Date: Mon, 10 Jan 2022 11:53:44 +0100 Subject: [PATCH] Add spec for method PackageBuildStatus#check_everbuilt --- .../no_job_history/1_5_1_1.yml | 149 ++++++++++++++++++ .../no_job_history/1_5_1_2.yml | 149 ++++++++++++++++++ .../with_job_history/1_5_2_1.yml | 81 ++++++++++ .../spec/models/package_build_status_spec.rb | 34 ++++ 4 files changed, 413 insertions(+) create mode 100644 src/api/spec/cassettes/PackageBuildStatus/_check_everbuilt/no_job_history/1_5_1_1.yml create mode 100644 src/api/spec/cassettes/PackageBuildStatus/_check_everbuilt/no_job_history/1_5_1_2.yml create mode 100644 src/api/spec/cassettes/PackageBuildStatus/_check_everbuilt/with_job_history/1_5_2_1.yml diff --git a/src/api/spec/cassettes/PackageBuildStatus/_check_everbuilt/no_job_history/1_5_1_1.yml b/src/api/spec/cassettes/PackageBuildStatus/_check_everbuilt/no_job_history/1_5_1_1.yml new file mode 100644 index 00000000000..6b2a0fea805 --- /dev/null +++ b/src/api/spec/cassettes/PackageBuildStatus/_check_everbuilt/no_job_history/1_5_1_1.yml @@ -0,0 +1,149 @@ +--- +http_interactions: +- request: + method: put + uri: http://backend:5352/source/home:foo/_meta?user=foo + body: + encoding: UTF-8 + string: | + + + <description/> + <person userid="foo" role="maintainer"/> + </project> + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '128' + body: + encoding: UTF-8 + string: | + <project name="home:foo"> + <title> + + + + recorded_at: Mon, 10 Jan 2022 10:51:56 GMT +- request: + method: put + uri: http://backend:5352/source/home:foo/foo/_meta?user=foo + body: + encoding: UTF-8 + string: | + + The Man Within + Dolores at nisi vitae. + + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '135' + body: + encoding: UTF-8 + string: | + + The Man Within + Dolores at nisi vitae. + + recorded_at: Mon, 10 Jan 2022 10:51:56 GMT +- request: + method: get + uri: http://backend:5352/build/home:foo/foo/i386/_jobhistory?code=lastfailures&limit=2&package=foo + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 404 + message: project 'home foo' has no repository 'foo' + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '162' + body: + encoding: UTF-8 + string: | + + project 'home:foo' has no repository 'foo' +
404 project 'home:foo' has no repository 'foo'
+
+ recorded_at: Mon, 10 Jan 2022 10:51:56 GMT +- request: + method: get + uri: http://backend:5352/build/home:foo/foo/i386/_jobhistory?limit=20&package=foo + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 404 + message: project 'home foo' has no repository 'foo' + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '162' + body: + encoding: UTF-8 + string: | + + project 'home:foo' has no repository 'foo' +
404 project 'home:foo' has no repository 'foo'
+
+ recorded_at: Mon, 10 Jan 2022 10:51:56 GMT +recorded_with: VCR 6.0.0 diff --git a/src/api/spec/cassettes/PackageBuildStatus/_check_everbuilt/no_job_history/1_5_1_2.yml b/src/api/spec/cassettes/PackageBuildStatus/_check_everbuilt/no_job_history/1_5_1_2.yml new file mode 100644 index 00000000000..ba2dba2784b --- /dev/null +++ b/src/api/spec/cassettes/PackageBuildStatus/_check_everbuilt/no_job_history/1_5_1_2.yml @@ -0,0 +1,149 @@ +--- +http_interactions: +- request: + method: put + uri: http://backend:5352/source/home:foo/_meta?user=foo + body: + encoding: UTF-8 + string: | + + + <description/> + <person userid="foo" role="maintainer"/> + </project> + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '128' + body: + encoding: UTF-8 + string: | + <project name="home:foo"> + <title> + + + + recorded_at: Mon, 10 Jan 2022 10:51:55 GMT +- request: + method: put + uri: http://backend:5352/source/home:foo/foo/_meta?user=foo + body: + encoding: UTF-8 + string: | + + The Golden Apples of the Sun + Cupiditate nemo quibusdam voluptas. + + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '162' + body: + encoding: UTF-8 + string: | + + The Golden Apples of the Sun + Cupiditate nemo quibusdam voluptas. + + recorded_at: Mon, 10 Jan 2022 10:51:55 GMT +- request: + method: get + uri: http://backend:5352/build/home:foo/foo/i386/_jobhistory?code=lastfailures&limit=2&package=foo + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 404 + message: project 'home foo' has no repository 'foo' + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '162' + body: + encoding: UTF-8 + string: | + + project 'home:foo' has no repository 'foo' +
404 project 'home:foo' has no repository 'foo'
+
+ recorded_at: Mon, 10 Jan 2022 10:51:55 GMT +- request: + method: get + uri: http://backend:5352/build/home:foo/foo/i386/_jobhistory?limit=20&package=foo + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 404 + message: project 'home foo' has no repository 'foo' + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '162' + body: + encoding: UTF-8 + string: | + + project 'home:foo' has no repository 'foo' +
404 project 'home:foo' has no repository 'foo'
+
+ recorded_at: Mon, 10 Jan 2022 10:51:55 GMT +recorded_with: VCR 6.0.0 diff --git a/src/api/spec/cassettes/PackageBuildStatus/_check_everbuilt/with_job_history/1_5_2_1.yml b/src/api/spec/cassettes/PackageBuildStatus/_check_everbuilt/with_job_history/1_5_2_1.yml new file mode 100644 index 00000000000..0b4404fb26c --- /dev/null +++ b/src/api/spec/cassettes/PackageBuildStatus/_check_everbuilt/with_job_history/1_5_2_1.yml @@ -0,0 +1,81 @@ +--- +http_interactions: +- request: + method: put + uri: http://backend:5352/source/home:foo/_meta?user=foo + body: + encoding: UTF-8 + string: | + + + <description/> + <person userid="foo" role="maintainer"/> + </project> + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '128' + body: + encoding: UTF-8 + string: | + <project name="home:foo"> + <title> + + + + recorded_at: Mon, 10 Jan 2022 10:51:56 GMT +- request: + method: put + uri: http://backend:5352/source/home:foo/foo/_meta?user=foo + body: + encoding: UTF-8 + string: | + + The World, the Flesh and the Devil + Quis est repellat placeat. + + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - text/xml + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '159' + body: + encoding: UTF-8 + string: | + + The World, the Flesh and the Devil + Quis est repellat placeat. + + recorded_at: Mon, 10 Jan 2022 10:51:56 GMT +recorded_with: VCR 6.0.0 diff --git a/src/api/spec/models/package_build_status_spec.rb b/src/api/spec/models/package_build_status_spec.rb index 6fb8f02454a..f85f6eb92a4 100644 --- a/src/api/spec/models/package_build_status_spec.rb +++ b/src/api/spec/models/package_build_status_spec.rb @@ -41,4 +41,38 @@ it { expect { subject }.not_to raise_error } it { expect(subject).to be_a(Hash) } end + + describe '#check_everbuilt' do + let(:arch_name) { 'i386' } + let(:repo_hash) { { 'name' => 'foo' } } + let(:package_build_status) { described_class.new(package) } + + subject { package_build_status.check_everbuilt(repo_hash, arch_name) } + + context 'no job history' do + it { expect { subject }.not_to raise_error } + it { expect(subject.instance_variable_get(:@everbuilt)).to be_falsey } + end + + context 'with job history' do + let(:md5sum) { 'c157a79031e1c40f85931829bc5fc552' } + let(:local_job_history) do + LocalJobHistory.new( + arch: arch_name, + repository: repo_hash['name'], + verifymd5: md5sum, + srcmd5: md5sum, + code: 'succeeded' + ) + end + + before do + package_build_status.instance_variable_set(:@srcmd5, md5sum) + allow(Backend::Api::BuildResults::JobHistory).to receive(:for_package).and_return([local_job_history]) + subject + end + + it { expect(package_build_status.instance_variable_get(:@everbuilt)).to be_truthy } + end + end end