Skip to content

Commit 9035bd0

Browse files
authored
Merge pull request #1359 from basecamp/add-env-precedence-tests
Add tests for env/secret file precedence
2 parents f1a9a09 + dd8cadf commit 9035bd0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/secrets_test.rb

+14
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,20 @@ class SecretsTest < ActiveSupport::TestCase
2020
end
2121
end
2222

23+
test "env references" do
24+
with_test_secrets("secrets" => "SECRET1=$SECRET1") do
25+
ENV["SECRET1"] = "ABC"
26+
assert_equal "ABC", Kamal::Secrets.new["SECRET1"]
27+
end
28+
end
29+
30+
test "secrets file value overrides env" do
31+
with_test_secrets("secrets" => "SECRET1=DEF") do
32+
ENV["SECRET1"] = "ABC"
33+
assert_equal "DEF", Kamal::Secrets.new["SECRET1"]
34+
end
35+
end
36+
2337
test "destinations" do
2438
with_test_secrets("secrets.dest" => "SECRET=DEF", "secrets" => "SECRET=ABC", "secrets-common" => "SECRET=GHI\nSECRET2=JKL") do
2539
assert_equal "ABC", Kamal::Secrets.new["SECRET"]

0 commit comments

Comments
 (0)