Merge pull request #30 from azolf/improve-test-coverage
Improve test coverage
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,2 +1,4 @@
|
|||||||
.byebug_history
|
.byebug_history
|
||||||
*.gem
|
*.gem
|
||||||
|
coverage/*
|
||||||
|
.DS_Store
|
||||||
25
test/commands/registry_test.rb
Executable file
25
test/commands/registry_test.rb
Executable file
@@ -0,0 +1,25 @@
|
|||||||
|
require "test_helper"
|
||||||
|
require "mrsk/configuration"
|
||||||
|
require "mrsk/commands/registry"
|
||||||
|
|
||||||
|
class CommandsRegistryTest < ActiveSupport::TestCase
|
||||||
|
setup do
|
||||||
|
@config = { service: "app",
|
||||||
|
image: "dhh/app",
|
||||||
|
registry: { "username" => "dhh",
|
||||||
|
"password" => "secret",
|
||||||
|
"server" => "hub.docker.com"
|
||||||
|
},
|
||||||
|
servers: [ "1.1.1.1" ]
|
||||||
|
}
|
||||||
|
@registry = Mrsk::Commands::Registry.new Mrsk::Configuration.new(@config)
|
||||||
|
end
|
||||||
|
|
||||||
|
test "registry login" do
|
||||||
|
assert_equal [ :docker, :login, "hub.docker.com", "-u", "dhh", "-p", "secret" ], @registry.login
|
||||||
|
end
|
||||||
|
|
||||||
|
test "registry logout" do
|
||||||
|
assert_equal [:docker, :logout, "hub.docker.com"], @registry.logout
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -16,6 +16,61 @@ class CommandsTraefikTest < ActiveSupport::TestCase
|
|||||||
new_command.run
|
new_command.run
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "traefik start" do
|
||||||
|
assert_equal \
|
||||||
|
[:docker, :container, :start, 'traefik'], new_command.start
|
||||||
|
end
|
||||||
|
|
||||||
|
test "traefik stop" do
|
||||||
|
assert_equal \
|
||||||
|
[:docker, :container, :stop, 'traefik'], new_command.stop
|
||||||
|
end
|
||||||
|
|
||||||
|
test "traefik info" do
|
||||||
|
assert_equal \
|
||||||
|
[:docker, :ps, '--filter', 'name=traefik'], new_command.info
|
||||||
|
end
|
||||||
|
|
||||||
|
test "traefik logs" do
|
||||||
|
assert_equal \
|
||||||
|
[:docker, :logs, 'traefik', '-t', '2>&1'], new_command.logs
|
||||||
|
end
|
||||||
|
|
||||||
|
test "traefik logs since 2h" do
|
||||||
|
assert_equal \
|
||||||
|
[:docker, :logs, 'traefik', ' --since 2h', '-t', '2>&1'], new_command.logs(since: '2h')
|
||||||
|
end
|
||||||
|
|
||||||
|
test "traefik logs last 10 lines" do
|
||||||
|
assert_equal \
|
||||||
|
[:docker, :logs, 'traefik', ' -n 10', '-t', '2>&1'], new_command.logs(lines: 10)
|
||||||
|
end
|
||||||
|
|
||||||
|
test "traefik logs with grep hello!" do
|
||||||
|
assert_equal \
|
||||||
|
[:docker, :logs, 'traefik', '-t', '2>&1', "|", "grep 'hello!'"], new_command.logs(grep: 'hello!')
|
||||||
|
end
|
||||||
|
|
||||||
|
test "traefik remove container" do
|
||||||
|
assert_equal \
|
||||||
|
[:docker, :container, :prune, "-f", "--filter", "label=org.opencontainers.image.title=Traefik"], new_command.remove_container
|
||||||
|
end
|
||||||
|
|
||||||
|
test "traefik remove image" do
|
||||||
|
assert_equal \
|
||||||
|
[:docker, :image, :prune, "-a", "-f", "--filter", "label=org.opencontainers.image.title=Traefik"], new_command.remove_image
|
||||||
|
end
|
||||||
|
|
||||||
|
test "traefik follow logs" do
|
||||||
|
assert_equal \
|
||||||
|
"ssh -t root@1.1.1.1 'docker logs traefik -t -n 10 -f 2>&1'", new_command.follow_logs(host: @config[:servers].first)
|
||||||
|
end
|
||||||
|
|
||||||
|
test "traefik follow logs with grep hello!" do
|
||||||
|
assert_equal \
|
||||||
|
"ssh -t root@1.1.1.1 'docker logs traefik -t -n 10 -f 2>&1 | grep \"hello!\"'", new_command.follow_logs(host: @config[:servers].first, grep: 'hello!')
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def new_command
|
def new_command
|
||||||
Mrsk::Commands::Traefik.new(Mrsk::Configuration.new(@config, version: "123"))
|
Mrsk::Commands::Traefik.new(Mrsk::Configuration.new(@config, version: "123"))
|
||||||
|
|||||||
Reference in New Issue
Block a user