-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into jylee/deletedefaultclasses
- Loading branch information
Showing
8 changed files
with
96 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,6 +134,12 @@ def add_init_container(container) | |
it "sets name for unknown kinds" do | ||
raw_template[:kind] = "foobar" | ||
template.to_hash[:metadata][:name].must_equal "test-app-server" | ||
|
||
it "adds deploy url to resource and templates" do | ||
result = template.to_hash | ||
result.dig(:metadata, :annotations, :"samson/deploy_url").must_equal doc.kubernetes_release.deploy.url | ||
result.dig(:spec, :template, :metadata, :annotations, :"samson/deploy_url"). | ||
must_equal doc.kubernetes_release.deploy.url | ||
end | ||
|
||
describe "unqiue deployments" do | ||
|
@@ -166,49 +172,14 @@ def add_init_container(container) | |
end | ||
end | ||
|
||
describe "deployer" do | ||
let(:result) { template.to_hash.dig_fetch(:spec, :template, :metadata, :annotations, :deployer) } | ||
|
||
it "sets deployer" do | ||
result.must_equal "[email protected]" | ||
end | ||
|
||
it "does not set nil deployer which breaks kubernetes api" do | ||
doc.kubernetes_release.user.email = nil | ||
result.must_equal "" | ||
end | ||
end | ||
|
||
describe "owner" do | ||
let(:result) { template.to_hash.dig_fetch(:spec, :template, :metadata, :annotations, :owner) } | ||
|
||
it "sets owner" do | ||
project.owner = "[email protected]" | ||
result.must_equal "[email protected]" | ||
end | ||
|
||
it "does not set nil owner which breaks kubernetes api" do | ||
project.owner = nil | ||
result.must_equal "" | ||
end | ||
end | ||
|
||
describe "github-repo" do | ||
let(:result) { template.to_hash.dig_fetch(:spec, :template, :metadata, :annotations, :"samson/github-repo") } | ||
|
||
it "sets github-repo" do | ||
result.must_equal "bar/foo" | ||
end | ||
end | ||
|
||
describe "configmap" do | ||
it "only modifies namespace since there is no template" do | ||
raw_template[:kind] = "ConfigMap" | ||
raw_template.delete(:spec) | ||
raw_template[:metadata][:namespace] = 'old' | ||
old = raw_template.deep_dup | ||
old[:metadata][:namespace] = 'pod1' | ||
template.to_hash.must_equal old | ||
result = template.to_hash | ||
result[:metadata][:namespace].must_equal 'pod1' | ||
refute result[:spec] | ||
end | ||
end | ||
|
||
|
@@ -834,9 +805,9 @@ def secret_annotations(hash) | |
end | ||
|
||
describe "when something is required" do | ||
let(:annotations) { raw_template[:spec][:template][:metadata][:annotations] = {} } | ||
let(:pod_annotations) { raw_template[:spec][:template][:metadata][:annotations] = {} } | ||
|
||
before { annotations[:"samson/required_env"] = 'FOO' } | ||
before { pod_annotations[:"samson/required_env"] = 'FOO' } | ||
|
||
it "fails when value is missing" do | ||
e = assert_raises Samson::Hooks::UserError do | ||
|
@@ -846,7 +817,7 @@ def secret_annotations(hash) | |
end | ||
|
||
it "fails when multiple values are missing" do | ||
annotations[:"samson/required_env"] = 'FOO BAR,BAZ, FOO2 FOO3' | ||
pod_annotations[:"samson/required_env"] = 'FOO BAR,BAZ, FOO2 FOO3' | ||
e = assert_raises Samson::Hooks::UserError do | ||
template.send(:verify_env) | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters