Commit 23edfce5 authored by Tiffany Rea's avatar Tiffany Rea

Refactor test to use a dynamic value for expectation

parent 2393b1eb
......@@ -5,34 +5,29 @@ require 'faker'
module QA
RSpec.describe 'Verify', :runner do
describe 'Pass dotenv variables to downstream via bridge' do
let(:executor_1) { "qa-runner-#{Faker::Alphanumeric.alphanumeric(8)}" }
let(:executor_2) { "qa-runner-#{Faker::Alphanumeric.alphanumeric(8)}" }
let(:executor) { "qa-runner-#{Faker::Alphanumeric.alphanumeric(8)}" }
let(:upstream_var) { Faker::Alphanumeric.alphanumeric(8) }
let(:group) { Resource::Group.fabricate_via_api! }
let(:upstream_project) do
Resource::Project.fabricate_via_api! do |project|
project.name = 'project-with-pipeline-1'
project.group = group
project.name = 'upstream-project-with-bridge'
end
end
let(:downstream_project) do
Resource::Project.fabricate_via_api! do |project|
project.name = 'project-with-pipeline-2'
project.group = group
project.name = 'downstream-project-with-bridge'
end
end
let!(:runner_1) do
let!(:runner) do
Resource::Runner.fabricate! do |runner|
runner.project = upstream_project
runner.name = executor_1
runner.tags = [executor_1]
end
end
let!(:runner_2) do
Resource::Runner.fabricate! do |runner|
runner.project = downstream_project
runner.name = executor_2
runner.tags = [executor_2]
runner.name = executor
runner.tags = [executor]
runner.token = group.sandbox.runners_token
end
end
......@@ -45,8 +40,8 @@ module QA
end
after do
runner_1.remove_via_api!
runner_2.remove_via_api!
runner.remove_via_api!
group.remove_via_api!
end
it 'runs the pipeline with composed config', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1086' do
......@@ -58,6 +53,7 @@ module QA
Page::Project::Job::Show.perform do |show|
expect(show).to have_passed(timeout: 360)
expect(show.output).to have_content(upstream_var)
end
end
......@@ -77,8 +73,9 @@ module QA
content: <<~YAML
build:
stage: build
tags: ["#{executor_1}"]
script: echo "MY_VAR=hello" >> variables.env
tags: ["#{executor}"]
script:
- echo "DYNAMIC_ENVIRONMENT_VAR=#{upstream_var}" >> variables.env
artifacts:
reports:
dotenv: variables.env
......@@ -86,7 +83,7 @@ module QA
trigger:
stage: deploy
variables:
PASSED_MY_VAR: $MY_VAR
PASSED_MY_VAR: $DYNAMIC_ENVIRONMENT_VAR
trigger: #{downstream_project.full_path}
YAML
}
......@@ -98,8 +95,9 @@ module QA
content: <<~YAML
downstream_test:
stage: test
tags: ["#{executor_2}"]
script: '[ "$PASSED_MY_VAR" = hello ]; exit "$?"'
tags: ["#{executor}"]
script:
- echo $PASSED_MY_VAR
YAML
}
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