Improve specs for GitlabCiYamlProcessor
This commit is contained in:
parent
7805eea3c7
commit
3e75fd6c5b
|
@ -596,13 +596,12 @@ module Ci
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "Image and service handling" do
|
describe "Image and service handling" do
|
||||||
|
context "when extended docker configuration is used" do
|
||||||
it "returns image and service when defined" do
|
it "returns image and service when defined" do
|
||||||
config = YAML.dump({
|
config = YAML.dump({ image: { name: "ruby:2.1" },
|
||||||
image: { name: "ruby:2.1" },
|
|
||||||
services: ["mysql", { name: "docker:dind", alias: "docker" }],
|
services: ["mysql", { name: "docker:dind", alias: "docker" }],
|
||||||
before_script: ["pwd"],
|
before_script: ["pwd"],
|
||||||
rspec: { script: "rspec" }
|
rspec: { script: "rspec" } })
|
||||||
})
|
|
||||||
|
|
||||||
config_processor = GitlabCiYamlProcessor.new(config, path)
|
config_processor = GitlabCiYamlProcessor.new(config, path)
|
||||||
|
|
||||||
|
@ -626,12 +625,67 @@ module Ci
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns image and service when overridden for job" do
|
it "returns image and service when overridden for job" do
|
||||||
config = YAML.dump({
|
config = YAML.dump({ image: "ruby:2.1",
|
||||||
image: "ruby:2.1",
|
|
||||||
services: ["mysql"],
|
services: ["mysql"],
|
||||||
before_script: ["pwd"],
|
before_script: ["pwd"],
|
||||||
rspec: { image: "ruby:2.5", services: [{ name: "postgresql" }, "docker:dind"], script: "rspec" }
|
rspec: { image: { name: "ruby:2.5" },
|
||||||
|
services: [{ name: "postgresql", alias: "db-pg" }, "docker:dind"], script: "rspec" } })
|
||||||
|
|
||||||
|
config_processor = GitlabCiYamlProcessor.new(config, path)
|
||||||
|
|
||||||
|
expect(config_processor.builds_for_stage_and_ref("test", "master").size).to eq(1)
|
||||||
|
expect(config_processor.builds_for_stage_and_ref("test", "master").first).to eq({
|
||||||
|
stage: "test",
|
||||||
|
stage_idx: 1,
|
||||||
|
name: "rspec",
|
||||||
|
commands: "pwd\nrspec",
|
||||||
|
coverage_regex: nil,
|
||||||
|
tag_list: [],
|
||||||
|
options: {
|
||||||
|
image: { name: "ruby:2.5" },
|
||||||
|
services: [{ name: "postgresql", alias: "db-pg" }, { name: "docker:dind" }]
|
||||||
|
},
|
||||||
|
allow_failure: false,
|
||||||
|
when: "on_success",
|
||||||
|
environment: nil,
|
||||||
|
yaml_variables: []
|
||||||
})
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when etended docker configuration is not used" do
|
||||||
|
it "returns image and service when defined" do
|
||||||
|
config = YAML.dump({ image: "ruby:2.1",
|
||||||
|
services: ["mysql", "docker:dind"],
|
||||||
|
before_script: ["pwd"],
|
||||||
|
rspec: { script: "rspec" } })
|
||||||
|
|
||||||
|
config_processor = GitlabCiYamlProcessor.new(config, path)
|
||||||
|
|
||||||
|
expect(config_processor.builds_for_stage_and_ref("test", "master").size).to eq(1)
|
||||||
|
expect(config_processor.builds_for_stage_and_ref("test", "master").first).to eq({
|
||||||
|
stage: "test",
|
||||||
|
stage_idx: 1,
|
||||||
|
name: "rspec",
|
||||||
|
commands: "pwd\nrspec",
|
||||||
|
coverage_regex: nil,
|
||||||
|
tag_list: [],
|
||||||
|
options: {
|
||||||
|
image: { name: "ruby:2.1" },
|
||||||
|
services: [{ name: "mysql" }, { name: "docker:dind" }]
|
||||||
|
},
|
||||||
|
allow_failure: false,
|
||||||
|
when: "on_success",
|
||||||
|
environment: nil,
|
||||||
|
yaml_variables: []
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns image and service when overridden for job" do
|
||||||
|
config = YAML.dump({ image: "ruby:2.1",
|
||||||
|
services: ["mysql"],
|
||||||
|
before_script: ["pwd"],
|
||||||
|
rspec: { image: "ruby:2.5", services: ["postgresql", "docker:dind"], script: "rspec" } })
|
||||||
|
|
||||||
config_processor = GitlabCiYamlProcessor.new(config, path)
|
config_processor = GitlabCiYamlProcessor.new(config, path)
|
||||||
|
|
||||||
|
@ -654,6 +708,7 @@ module Ci
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'Variables' do
|
describe 'Variables' do
|
||||||
let(:config_processor) { GitlabCiYamlProcessor.new(YAML.dump(config), path) }
|
let(:config_processor) { GitlabCiYamlProcessor.new(YAML.dump(config), path) }
|
||||||
|
|
Loading…
Reference in New Issue