Skip to content

Commit

Permalink
Add test coverage with aliases.
Browse files Browse the repository at this point in the history
  • Loading branch information
mdkent committed Nov 11, 2023
1 parent 99aedfc commit 53ffd97
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/cli/main_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,19 @@ class CliMainTest < CliTestCase
end
end

test "config with aliases" do
run_command("config", config_file: "deploy_with_aliases").tap do |output|
config = YAML.load(output)

assert_equal ["web", "web_tokyo", "workers", "workers_tokyo"], config[:roles]
assert_equal ["1.1.1.1", "1.1.1.2", "1.1.1.3", "1.1.1.4"], config[:hosts]
assert_equal "999", config[:version]
assert_equal "registry.digitalocean.com/dhh/app", config[:repository]
assert_equal "registry.digitalocean.com/dhh/app:999", config[:absolute_image]
assert_equal "app-999", config[:service_with_version]
end
end

test "init" do
Pathname.any_instance.expects(:exist?).returns(false).times(3)
Pathname.any_instance.stubs(:mkpath)
Expand Down
36 changes: 36 additions & 0 deletions test/fixtures/deploy_with_aliases.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# helper aliases
chicago_hosts: &chicago_hosts
hosts:
- 1.1.1.1
- 1.1.1.2
tokyo_hosts: &tokyo_hosts
hosts:
- 1.1.1.3
- 1.1.1.4
web_common: &web_common
env:
ROLE: "web"
traefik: true

# actual config
service: app
image: dhh/app
servers:
web:
<<: *chicago_hosts
<<: *web_common
web_tokyo:
<<: *tokyo_hosts
<<: *web_common
workers:
cmd: bin/jobs
<<: *chicago_hosts
workers_tokyo:
cmd: bin/jobs
<<: *tokyo_hosts
env:
REDIS_URL: redis://x/y
registry:
server: registry.digitalocean.com
username: user
password: pw

0 comments on commit 53ffd97

Please sign in to comment.