File: basic.bats

package info (click to toggle)
golang-github-containers-buildah 1.39.3%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,724 kB
  • sloc: sh: 2,398; makefile: 236; perl: 187; asm: 16; awk: 12; ansic: 1
file content (135 lines) | stat: -rw-r--r-- 4,475 bytes parent folder | download
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/env bats

load helpers

@test "from" {
  _prefetch alpine
  run_buildah from --quiet --pull=false $WITH_POLICY_JSON alpine
  cid=$output
  run_buildah rm $cid
  run_buildah from $WITH_POLICY_JSON scratch
  cid=$output
  run_buildah rm $cid
  run_buildah from --quiet --pull=false $WITH_POLICY_JSON --name i-love-naming-things alpine
  cid=$output
  run_buildah rm i-love-naming-things
}

@test "from-defaultpull" {
  _prefetch alpine
  run_buildah from --quiet $WITH_POLICY_JSON alpine
  cid=$output
  run_buildah rm $cid
}

@test "from-scratch" {
  run_buildah from --pull=false $WITH_POLICY_JSON scratch
  cid=$output
  run_buildah rm $cid
  run_buildah from --pull=true  $WITH_POLICY_JSON scratch
  cid=$output
  run_buildah rm $cid
}

@test "from-nopull" {
  run_buildah 125 from --pull-never $WITH_POLICY_JSON alpine
}

@test "mount" {
  run_buildah from $WITH_POLICY_JSON scratch
  cid=$output
  run_buildah mount $cid
  root=$output
  run_buildah unmount $cid
  run_buildah mount $cid
  root=$output
  touch $root/foobar
  run_buildah unmount $cid
  run_buildah rm $cid
}

@test "by-name" {
  run_buildah from $WITH_POLICY_JSON --name scratch-working-image-for-test scratch
  cid=$output
  run_buildah mount scratch-working-image-for-test
  root=$output
  run_buildah unmount scratch-working-image-for-test
  run_buildah rm scratch-working-image-for-test
}

@test "commit" {
  createrandom ${TEST_SCRATCH_DIR}/randomfile
  createrandom ${TEST_SCRATCH_DIR}/other-randomfile

  run_buildah from $WITH_POLICY_JSON scratch
  cid=$output
  run_buildah mount $cid
  root=$output
  cp ${TEST_SCRATCH_DIR}/randomfile $root/randomfile
  run_buildah unmount $cid
  run_buildah commit --iidfile ${TEST_SCRATCH_DIR}/output.iid $WITH_POLICY_JSON $cid containers-storage:new-image
  iid=$(< ${TEST_SCRATCH_DIR}/output.iid)
  assert "$iid" =~ "sha256:[0-9a-f]{64}"
  run_buildah rmi $iid
  run_buildah commit $WITH_POLICY_JSON $cid containers-storage:new-image
  run_buildah rm $cid
  run_buildah from --quiet $WITH_POLICY_JSON new-image
  newcid=$output
  run_buildah mount $newcid
  newroot=$output
  test -s $newroot/randomfile
  cmp ${TEST_SCRATCH_DIR}/randomfile $newroot/randomfile
  cp ${TEST_SCRATCH_DIR}/other-randomfile $newroot/other-randomfile
  run_buildah commit $WITH_POLICY_JSON $newcid containers-storage:other-new-image
  # Not an allowed ordering of arguments and flags.  Check that it's rejected.
  run_buildah 125 commit $newcid $WITH_POLICY_JSON containers-storage:rejected-new-image
  run_buildah commit $WITH_POLICY_JSON $newcid containers-storage:another-new-image
  run_buildah commit $WITH_POLICY_JSON $newcid yet-another-new-image
  run_buildah commit $WITH_POLICY_JSON $newcid containers-storage:gratuitous-new-image
  run_buildah unmount $newcid
  run_buildah rm $newcid

  run_buildah from --quiet $WITH_POLICY_JSON other-new-image
  othernewcid=$output
  run_buildah mount $othernewcid
  othernewroot=$output
  test -s $othernewroot/randomfile
  cmp ${TEST_SCRATCH_DIR}/randomfile $othernewroot/randomfile
  test -s $othernewroot/other-randomfile
  cmp ${TEST_SCRATCH_DIR}/other-randomfile $othernewroot/other-randomfile
  run_buildah rm $othernewcid

  run_buildah from --quiet $WITH_POLICY_JSON another-new-image
  anothernewcid=$output
  run_buildah mount $anothernewcid
  anothernewroot=$output
  test -s $anothernewroot/randomfile
  cmp ${TEST_SCRATCH_DIR}/randomfile $anothernewroot/randomfile
  test -s $anothernewroot/other-randomfile
  cmp ${TEST_SCRATCH_DIR}/other-randomfile $anothernewroot/other-randomfile
  run_buildah rm $anothernewcid

  run_buildah from --quiet $WITH_POLICY_JSON yet-another-new-image
  yetanothernewcid=$output
  run_buildah mount $yetanothernewcid
  yetanothernewroot=$output
  test -s $yetanothernewroot/randomfile
  cmp ${TEST_SCRATCH_DIR}/randomfile $yetanothernewroot/randomfile
  test -s $yetanothernewroot/other-randomfile
  cmp ${TEST_SCRATCH_DIR}/other-randomfile $yetanothernewroot/other-randomfile
  run_buildah delete $yetanothernewcid

  run_buildah from --quiet $WITH_POLICY_JSON new-image
  newcid=$output
  run_buildah commit --rm $WITH_POLICY_JSON $newcid containers-storage:remove-container-image
  run_buildah 125 mount $newcid

  run_buildah rmi remove-container-image
  run_buildah rmi containers-storage:other-new-image
  run_buildah rmi another-new-image
  run_buildah images -q
  assert "$output" != "" "images -q"
  run_buildah rmi -a
  run_buildah images -q
  expect_output ""
}