Add file mapping to accessories
This commit is contained in:
@@ -5,13 +5,18 @@ require "mrsk/cli"
|
||||
class CliAccessoryTest < ActiveSupport::TestCase
|
||||
include ActiveSupport::Testing::Stream
|
||||
|
||||
test "boot" do
|
||||
ENV["MYSQL_ROOT_PASSWORD"] = "secret123"
|
||||
setup { ENV["MYSQL_ROOT_PASSWORD"] = "secret123" }
|
||||
teardown { ENV["MYSQL_ROOT_PASSWORD"] = nil }
|
||||
|
||||
test "upload" do
|
||||
command = stdouted { Mrsk::Cli::Accessory.start(["upload", "mysql", "-c", "test/fixtures/deploy_with_accessories.yml"]) }
|
||||
|
||||
assert_match "test/fixtures/files/my.cnf app-mysql/etc/mysql/my.cnf", command
|
||||
end
|
||||
|
||||
test "boot" do
|
||||
command = stdouted { Mrsk::Cli::Accessory.start(["boot", "mysql", "-c", "test/fixtures/deploy_with_accessories.yml"]) }
|
||||
|
||||
assert_match "Running docker run --name app-mysql -d --restart unless-stopped -p 3306:3306 -e [REDACTED] -e MYSQL_ROOT_HOST=% --volume /var/lib/mysql:/var/lib/mysql --label service=app-mysql mysql:5.7 on 1.1.1.3", command
|
||||
ensure
|
||||
ENV["MYSQL_ROOT_PASSWORD"] = nil
|
||||
assert_match "Running docker run --name app-mysql -d --restart unless-stopped -p 3306:3306 -e [REDACTED] -e MYSQL_ROOT_HOST=% --volume /var/lib/mysql:/var/lib/mysql --volume app-mysql/etc/mysql/my.cnf:/etc/mysql/my.cnf --label service=app-mysql mysql:5.7 on 1.1.1.3", command
|
||||
end
|
||||
end
|
||||
|
||||
@@ -18,8 +18,12 @@ class ConfigurationAccessoryTest < ActiveSupport::TestCase
|
||||
},
|
||||
"secret" => [
|
||||
"MYSQL_ROOT_PASSWORD"
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
"files" => [
|
||||
"config/mysql/my.cnf:/etc/mysql/my.cnf",
|
||||
"db/structure.sql:/docker-entrypoint-initdb.d/structure.sql"
|
||||
]
|
||||
},
|
||||
"redis" => {
|
||||
"image" => "redis:latest",
|
||||
@@ -83,7 +87,7 @@ class ConfigurationAccessoryTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
test "volume args" do
|
||||
assert_equal [], @config.accessory(:mysql).volume_args
|
||||
assert_equal ["--volume", "app-mysql/etc/mysql/my.cnf:/etc/mysql/my.cnf", "--volume", "app-mysql/docker-entrypoint-initdb.d/structure.sql:/docker-entrypoint-initdb.d/structure.sql"], @config.accessory(:mysql).volume_args
|
||||
assert_equal ["--volume", "/var/lib/redis:/data"], @config.accessory(:redis).volume_args
|
||||
end
|
||||
end
|
||||
|
||||
2
test/fixtures/deploy_with_accessories.yml
vendored
2
test/fixtures/deploy_with_accessories.yml
vendored
@@ -19,6 +19,8 @@ accessories:
|
||||
- MYSQL_ROOT_PASSWORD
|
||||
volumes:
|
||||
- /var/lib/mysql:/var/lib/mysql
|
||||
files:
|
||||
- test/fixtures/files/my.cnf:/etc/mysql/my.cnf
|
||||
redis:
|
||||
image: redis:latest
|
||||
host: 1.1.1.4
|
||||
|
||||
1
test/fixtures/files/my.cnf
vendored
Normal file
1
test/fixtures/files/my.cnf
vendored
Normal file
@@ -0,0 +1 @@
|
||||
# MySQL Config
|
||||
Reference in New Issue
Block a user