File: rm.bats

package info (click to toggle)
golang-github-containers-buildah 1.39.3%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,724 kB
  • sloc: sh: 2,398; makefile: 236; perl: 187; asm: 16; awk: 12; ansic: 1
file content (71 lines) | stat: -rw-r--r-- 2,355 bytes parent folder | download | duplicates (2)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env bats

load helpers

@test "rm-flags-order-verification" {
  run_buildah 125 rm cnt1 -a
  check_options_flag_err "-a"

  run_buildah 125 rm cnt1 --all cnt2
  check_options_flag_err "--all"
}

@test "remove multiple containers errors" {
  run_buildah 125 rm mycontainer1 mycontainer2 mycontainer3
  expect_output --from="${lines[0]}" "removing container \"mycontainer1\": container not known" "output line 1"
  expect_output --from="${lines[1]}" "removing container \"mycontainer2\": container not known" "output line 2"
  expect_output --from="${lines[2]}" "Error: removing container \"mycontainer3\": container not known" "output line 3"
  expect_line_count 3
}

@test "remove one container" {
  _prefetch alpine
  run_buildah from --quiet --pull=false $WITH_POLICY_JSON alpine
  cid=$output
  run_buildah rm "$cid"
}

@test "remove multiple containers" {
  _prefetch alpine busybox
  run_buildah from --quiet $WITH_POLICY_JSON alpine
  cid2=$output
  run_buildah from --quiet $WITH_POLICY_JSON busybox
  cid3=$output
  run_buildah rm "$cid2" "$cid3"
}

@test "remove all containers" {
  _prefetch alpine busybox
  run_buildah from $WITH_POLICY_JSON scratch
  cid1=$output
  run_buildah from --quiet $WITH_POLICY_JSON alpine
  cid2=$output
  run_buildah from --quiet $WITH_POLICY_JSON busybox
  cid3=$output
  run_buildah rm -a
}

@test "use conflicting commands to remove containers" {
  _prefetch alpine
  run_buildah from --quiet --pull=false $WITH_POLICY_JSON alpine
  cid=$output
  run_buildah 125 rm -a "$cid"
  expect_output --substring "when using the --all switch, you may not pass any containers names or IDs"
}

@test "remove a single tagged manifest list" {
  _prefetch busybox
  run_buildah manifest create manifestsample
  run_buildah manifest add manifestsample busybox
  run_buildah tag manifestsample manifestsample2
  run_buildah manifest rm manifestsample2
  # Output should only untag the listed manifest nothing else
  expect_output "untagged: localhost/manifestsample2:latest"
  run_buildah manifest rm manifestsample
  # Since actual list is getting removed it will also print the image id of list
  # So check for substring instead of exact match
  expect_output --substring "untagged: localhost/manifestsample:latest"
  # Check if busybox is still there
  run_buildah images
  expect_output --substring "busybox"
}