Commit f963a7b0 authored by Dan Davison's avatar Dan Davison

Merge branch 'refactor-pass-dotenv-spec' into 'master'

Refactor test to use a dynamic value for expectation

See merge request gitlab-org/gitlab!61510
parents 6b58586e 23edfce5
...@@ -5,34 +5,29 @@ require 'faker' ...@@ -5,34 +5,29 @@ require 'faker'
module QA module QA
RSpec.describe 'Verify', :runner do RSpec.describe 'Verify', :runner do
describe 'Pass dotenv variables to downstream via bridge' do describe 'Pass dotenv variables to downstream via bridge' do
let(:executor_1) { "qa-runner-#{Faker::Alphanumeric.alphanumeric(8)}" } let(:executor) { "qa-runner-#{Faker::Alphanumeric.alphanumeric(8)}" }
let(:executor_2) { "qa-runner-#{Faker::Alphanumeric.alphanumeric(8)}" } let(:upstream_var) { Faker::Alphanumeric.alphanumeric(8) }
let(:group) { Resource::Group.fabricate_via_api! }
let(:upstream_project) do let(:upstream_project) do
Resource::Project.fabricate_via_api! do |project| Resource::Project.fabricate_via_api! do |project|
project.name = 'project-with-pipeline-1' project.group = group
project.name = 'upstream-project-with-bridge'
end end
end end
let(:downstream_project) do let(:downstream_project) do
Resource::Project.fabricate_via_api! do |project| Resource::Project.fabricate_via_api! do |project|
project.name = 'project-with-pipeline-2' project.group = group
project.name = 'downstream-project-with-bridge'
end end
end end
let!(:runner_1) do let!(:runner) do
Resource::Runner.fabricate! do |runner| Resource::Runner.fabricate! do |runner|
runner.project = upstream_project runner.name = executor
runner.name = executor_1 runner.tags = [executor]
runner.tags = [executor_1] runner.token = group.sandbox.runners_token
end
end
let!(:runner_2) do
Resource::Runner.fabricate! do |runner|
runner.project = downstream_project
runner.name = executor_2
runner.tags = [executor_2]
end end
end end
...@@ -45,8 +40,8 @@ module QA ...@@ -45,8 +40,8 @@ module QA
end end
after do after do
runner_1.remove_via_api! runner.remove_via_api!
runner_2.remove_via_api! group.remove_via_api!
end end
it 'runs the pipeline with composed config', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1086' do it 'runs the pipeline with composed config', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1086' do
...@@ -58,6 +53,7 @@ module QA ...@@ -58,6 +53,7 @@ module QA
Page::Project::Job::Show.perform do |show| Page::Project::Job::Show.perform do |show|
expect(show).to have_passed(timeout: 360) expect(show).to have_passed(timeout: 360)
expect(show.output).to have_content(upstream_var)
end end
end end
...@@ -77,8 +73,9 @@ module QA ...@@ -77,8 +73,9 @@ module QA
content: <<~YAML content: <<~YAML
build: build:
stage: build stage: build
tags: ["#{executor_1}"] tags: ["#{executor}"]
script: echo "MY_VAR=hello" >> variables.env script:
- echo "DYNAMIC_ENVIRONMENT_VAR=#{upstream_var}" >> variables.env
artifacts: artifacts:
reports: reports:
dotenv: variables.env dotenv: variables.env
...@@ -86,7 +83,7 @@ module QA ...@@ -86,7 +83,7 @@ module QA
trigger: trigger:
stage: deploy stage: deploy
variables: variables:
PASSED_MY_VAR: $MY_VAR PASSED_MY_VAR: $DYNAMIC_ENVIRONMENT_VAR
trigger: #{downstream_project.full_path} trigger: #{downstream_project.full_path}
YAML YAML
} }
...@@ -98,8 +95,9 @@ module QA ...@@ -98,8 +95,9 @@ module QA
content: <<~YAML content: <<~YAML
downstream_test: downstream_test:
stage: test stage: test
tags: ["#{executor_2}"] tags: ["#{executor}"]
script: '[ "$PASSED_MY_VAR" = hello ]; exit "$?"' script:
- echo $PASSED_MY_VAR
YAML YAML
} }
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment