Skip to content

Commit 2005cd1

Browse files
committed
tests: add tests for using builder instance when existing and not
1 parent fe62bc0 commit 2005cd1

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

tests/builder-instances.bats

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,30 @@ teardown() {
8989
"~~~ :docker: Not Creating Builder Instance 'builder-name' as already exists
9090
~~~ :docker: Using Default Builder 'test' with Driver 'driver'"
9191
}
92+
93+
@test "Use Builder Instance that does not Exist" {
94+
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_BUILDER_USE=true
95+
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_BUILDER_NAME=builder-name
96+
97+
stub docker \
98+
"buildx inspect builder-name : exit 1"
99+
100+
run "$PWD"/hooks/pre-command
101+
102+
assert_failure
103+
assert_output "+++ 🚨 Builder Instance 'builder-name' does not exist"
104+
}
105+
106+
@test "Use Builder Instance that Exists" {
107+
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_BUILDER_USE=true
108+
export BUILDKITE_PLUGIN_DOCKER_COMPOSE_BUILDER_NAME=builder-name
109+
110+
stub docker \
111+
"buildx inspect builder-name : exit 0" \
112+
"buildx use builder-name : exit 0"
113+
114+
run "$PWD"/hooks/pre-command
115+
116+
assert_success
117+
assert_output "~~~ :docker: Using Builder Instance '$BUILDKITE_PLUGIN_DOCKER_COMPOSE_BUILDER_NAME'"
118+
}

0 commit comments

Comments
 (0)