Add a unit test for duplicate top-level compose volume names

The check itself already existed in load_compose_file() (same shape as the
already-tested duplicate network name); this was just missing coverage.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gv3s5jckJKzh6JkMoi2Akz
This commit is contained in:
2026-09-07 10:45:42 +00:00
parent 4ffc68a00e
commit a626ff2cdd
+15
View File
@@ -529,6 +529,21 @@ TEST_CASE("compose file: service volumes -- bind mounts (absolute-resolved, ro),
CHECK_FALSE(load_compose_file(relative_target).has_value());
}
TEST_CASE("compose file: duplicate top-level volume name is an error", "[unit]") {
ScratchXdgDirs scratch;
// A duplicate YAML mapping key under volumes: -- same shape as the
// already-tested duplicate service name (libyaml keeps both pairs
// rather than deduplicating).
auto path = write_compose(scratch.path(),
"services:\n"
" web:\n"
" image: busybox:latest\n"
"volumes:\n"
" applog:\n"
" applog:\n");
CHECK_FALSE(load_compose_file(path).has_value());
}
TEST_CASE("compose file: validate_compose_external_state -- env_file existence, external network existence",
"[unit]") {
ScratchXdgDirs scratch;