forked from docker-archive/classicswarm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrename.bats
51 lines (40 loc) · 1.2 KB
/
rename.bats
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env bats
load ../helpers
function teardown() {
swarm_manage_cleanup
stop_docker
}
@test "docker rename" {
start_docker_with_busybox 2
swarm_manage
docker_swarm run -d --name test_container busybox sleep 500
docker_swarm run -d --name another_container busybox sleep 500
# make sure container exists
run docker_swarm ps -a
[ "${#lines[@]}" -eq 3 ]
[[ "${output}" == *"test_container"* ]]
[[ "${output}" == *"another_container"* ]]
[[ "${output}" != *"rename_container"* ]]
# rename container, conflict and fail
run docker_swarm rename test_container another_container
[ "$status" -ne 0 ]
[[ "${output}" == *"Conflict"* ]]
# rename container, successful
docker_swarm rename test_container rename_container
# verify after, rename
run docker_swarm ps -a
[ "${#lines[@]}" -eq 3 ]
[[ "${output}" == *"rename_container"* ]]
[[ "${output}" == *"another_container"* ]]
[[ "${output}" != *"test_container"* ]]
}
@test "docker rename conflict" {
start_docker_with_busybox 1
swarm_manage
id=$(docker_swarm create busybox)
prefix=$(printf "$id" | cut -c 1-4)
docker_swarm create --name test busybox
docker_swarm rename test "$prefix"
run docker_swarm rename test "$id"
[ "$status" -eq 1 ]
}