File: rename.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 (37 lines) | stat: -rw-r--r-- 1,067 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
#!/usr/bin/env bats

load helpers

@test "rename" {
  _prefetch alpine
  new_name=test-container
  run_buildah from --quiet --pull=false $WITH_POLICY_JSON alpine
  cid=$output
  run_buildah containers --format "{{.ContainerName}}"
  old_name=$output
  run_buildah rename ${cid} ${new_name}

  run_buildah containers --format "{{.ContainerName}}"
  expect_output --substring "test-container"

  run_buildah containers --quiet -f name=${old_name}
  expect_output ""
}

@test "rename same name as current name" {
  _prefetch alpine
  run_buildah from --quiet --pull=false $WITH_POLICY_JSON alpine
  cid=$output
  run_buildah 125 rename ${cid} ${cid}
  expect_output 'Error: renaming a container with the same name as its current name'
}

@test "rename same name as other container name" {
  _prefetch alpine busybox
  run_buildah from --quiet --pull=false $WITH_POLICY_JSON alpine
  cid1=$output
  run_buildah from --quiet --pull=false $WITH_POLICY_JSON busybox
  cid2=$output
  run_buildah 125 rename ${cid1} ${cid2}
  expect_output --substring " already in use by "
}