Fix tests

This commit is contained in:
David Heinemeier Hansson
2023-03-24 14:35:17 +01:00
parent 93423f2f20
commit 494e29d672
2 changed files with 6 additions and 20 deletions

View File

@@ -3,10 +3,7 @@ require_relative "cli_test_case"
class CliAppTest < CliTestCase
test "boot" do
# Stub current version fetch
SSHKit::Backend::Abstract.any_instance.stubs(:capture)
.returns("999") # new version
.then
.returns("123") # old version
SSHKit::Backend::Abstract.any_instance.stubs(:capture).returns("123") # old version
run_command("boot").tap do |output|
assert_match "docker run --detach --restart unless-stopped", output
@@ -27,7 +24,7 @@ class CliAppTest < CliTestCase
run_command("boot").tap do |output|
assert_match "Rebooting container with same version latest already deployed", output # Can't start what's already running
assert_match "docker container ls --all --filter name=app-latest --quiet | xargs docker container rm", output # Remove old container
assert_match "docker container ls --all --filter name=app-web-latest --quiet | xargs docker container rm", output # Remove old container
assert_match "docker run", output # Start new container
end
ensure
@@ -80,7 +77,7 @@ class CliAppTest < CliTestCase
test "exec" do
run_command("exec", "ruby -v").tap do |output|
assert_match "docker run --rm dhh/app:999 ruby -v", output
assert_match "docker run --rm dhh/app:latest ruby -v", output
end
end

View File

@@ -11,16 +11,6 @@ class CommanderTest < ActiveSupport::TestCase
assert_equal Mrsk::Configuration, @mrsk.config.class
end
test "commit hash as version" do
assert_equal `git rev-parse HEAD`.strip, @mrsk.config.version
end
test "commit hash as version but not in git" do
@mrsk.expects(:system).with("git rev-parse").returns(nil)
error = assert_raises(RuntimeError) { @mrsk.config }
assert_match /no git repository found/, error.message
end
test "overwriting hosts" do
assert_equal [ "1.1.1.1", "1.1.1.2", "1.1.1.3", "1.1.1.4" ], @mrsk.hosts
@@ -29,7 +19,7 @@ class CommanderTest < ActiveSupport::TestCase
end
test "filtering hosts by filtering roles" do
assert_equal [ "1.1.1.1", "1.1.1.2", "1.1.1.3" ], @mrsk.hosts
assert_equal [ "1.1.1.1", "1.1.1.2", "1.1.1.3", "1.1.1.4" ], @mrsk.hosts
@mrsk.specific_roles = [ "web" ]
assert_equal [ "1.1.1.1", "1.1.1.2" ], @mrsk.hosts
@@ -50,7 +40,7 @@ class CommanderTest < ActiveSupport::TestCase
end
test "overwriting hosts with primary" do
assert_equal [ "1.1.1.1", "1.1.1.2", "1.1.1.3" ], @mrsk.hosts
assert_equal [ "1.1.1.1", "1.1.1.2", "1.1.1.3", "1.1.1.4" ], @mrsk.hosts
@mrsk.specific_primary!
assert_equal [ "1.1.1.1" ], @mrsk.hosts
@@ -62,8 +52,7 @@ class CommanderTest < ActiveSupport::TestCase
end
test "roles_on" do
assert_equal [ "web", "workers" ], @mrsk.roles_on("1.1.1.1")
assert_equal [ "web" ], @mrsk.roles_on("1.1.1.2")
assert_equal [ "web" ], @mrsk.roles_on("1.1.1.1")
assert_equal [ "workers" ], @mrsk.roles_on("1.1.1.3")
end
end