Remove redundant test
This commit is contained in:
committed by
Donal McBreen
parent
3f37fea7c3
commit
0c6a593554
@@ -0,0 +1,50 @@
|
|||||||
|
require_relative "cli_test_case"
|
||||||
|
|
||||||
|
class CliSecretsTest < CliTestCase
|
||||||
|
test "login" do
|
||||||
|
run_command("login").tap do |output|
|
||||||
|
assert_match /docker login -u \[REDACTED\] -p \[REDACTED\] as .*@localhost/, output
|
||||||
|
assert_match /docker login -u \[REDACTED\] -p \[REDACTED\] on 1.1.1.\d/, output
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
test "fetch" do
|
||||||
|
run_command("login", "-L").tap do |output|
|
||||||
|
assert_no_match /docker login -u \[REDACTED\] -p \[REDACTED\] as .*@localhost/, output
|
||||||
|
assert_match /docker login -u \[REDACTED\] -p \[REDACTED\] on 1.1.1.\d/, output
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
test "fetch_all" do
|
||||||
|
run_command("login", "-R").tap do |output|
|
||||||
|
assert_match /docker login -u \[REDACTED\] -p \[REDACTED\] as .*@localhost/, output
|
||||||
|
assert_no_match /docker login -u \[REDACTED\] -p \[REDACTED\] on 1.1.1.\d/, output
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
test "extract" do
|
||||||
|
run_command("logout").tap do |output|
|
||||||
|
assert_match /docker logout as .*@localhost/, output
|
||||||
|
assert_match /docker logout on 1.1.1.\d/, output
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logout skip local" do
|
||||||
|
run_command("logout", "-L").tap do |output|
|
||||||
|
assert_no_match /docker logout as .*@localhost/, output
|
||||||
|
assert_match /docker logout on 1.1.1.\d/, output
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
test "logout skip remote" do
|
||||||
|
run_command("logout", "-R").tap do |output|
|
||||||
|
assert_match /docker logout as .*@localhost/, output
|
||||||
|
assert_no_match /docker logout on 1.1.1.\d/, output
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def run_command(*command)
|
||||||
|
stdouted { Kamal::Cli::Secrets.start([ *command, "-c", "test/fixtures/deploy_with_accessories.yml" ]) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|||||||
@@ -1,76 +0,0 @@
|
|||||||
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_str won't escape chinese characters" do
|
|
||||||
env = {
|
|
||||||
"foo" => '你好 means hello, "欢迎" means welcome, that\'s simple! 😃 {smile}'
|
|
||||||
}
|
|
||||||
|
|
||||||
assert_equal "foo=你好 means hello, \"欢迎\" means welcome, that's simple! 😃 {smile}\n",
|
|
||||||
Kamal::EnvFile.new(env).to_s
|
|
||||||
end
|
|
||||||
|
|
||||||
test "to_s won't escape japanese characters" do
|
|
||||||
env = {
|
|
||||||
"foo" => 'こんにちは means hello, "ようこそ" means welcome, that\'s simple! 😃 {smile}'
|
|
||||||
}
|
|
||||||
|
|
||||||
assert_equal "foo=こんにちは means hello, \"ようこそ\" means welcome, that's simple! 😃 {smile}\n", \
|
|
||||||
Kamal::EnvFile.new(env).to_s
|
|
||||||
end
|
|
||||||
|
|
||||||
test "to_s won't escape korean characters" do
|
|
||||||
env = {
|
|
||||||
"foo" => '안녕하세요 means hello, "어서 오십시오" means welcome, that\'s simple! 😃 {smile}'
|
|
||||||
}
|
|
||||||
|
|
||||||
assert_equal "foo=안녕하세요 means hello, \"어서 오십시오\" means welcome, that's simple! 😃 {smile}\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
|
|
||||||
Reference in New Issue
Block a user