Secret and clear env variables have different lifecycles. The clear ones are part of the repo, so it makes sense to always deploy them with the rest of the repo. The secret ones are external so we can't be sure that they are up to date, therefore they require an explicit push via `envify` or `env push`. We'll keep the env file, but now it just contains secrets. The clear values are passed directly to `docker run`.
50 lines
901 B
Ruby
50 lines
901 B
Ruby
require "test_helper"
|
|
|
|
class EnvFileTest < ActiveSupport::TestCase
|
|
test "to_s" do
|
|
env = {
|
|
"foo" => "bar",
|
|
"baz" => "haz"
|
|
}
|
|
|
|
assert_equal "foo=bar\nbaz=haz\n", \
|
|
Kamal::EnvFile.new(env).to_s
|
|
end
|
|
|
|
test "to_s empty" do
|
|
assert_equal "\n", Kamal::EnvFile.new({}).to_s
|
|
end
|
|
|
|
test "to_s escaped newline" do
|
|
env = {
|
|
"foo" => "hello\\nthere"
|
|
}
|
|
|
|
assert_equal "foo=hello\\\\nthere\n", \
|
|
Kamal::EnvFile.new(env).to_s
|
|
ensure
|
|
ENV.delete "PASSWORD"
|
|
end
|
|
|
|
test "to_s newline" do
|
|
env = {
|
|
"foo" => "hello\nthere"
|
|
}
|
|
|
|
assert_equal "foo=hello\\nthere\n", \
|
|
Kamal::EnvFile.new(env).to_s
|
|
ensure
|
|
ENV.delete "PASSWORD"
|
|
end
|
|
|
|
test "stringIO conversion" do
|
|
env = {
|
|
"foo" => "bar",
|
|
"baz" => "haz"
|
|
}
|
|
|
|
assert_equal "foo=bar\nbaz=haz\n", \
|
|
StringIO.new(Kamal::EnvFile.new(env)).read
|
|
end
|
|
end
|