blob: da6f2177c6af480167760a6bd609b74d75d295a4 (
plain)
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 "podman history - basic tests" {
tests="
| .*[0-9a-f]\\\{12\\\} .* CMD .* LABEL
--format '{{.ID}} {{.Created}}' | .*[0-9a-f]\\\{12\\\} .* ago
--human=false | .*[0-9a-f]\\\{12\\\} *[0-9-]\\\+T[0-9:]\\\+Z
-qH | .*[0-9a-f]\\\{12\\\}
--no-trunc | .*[0-9a-f]\\\{64\\\}
"
parse_table "$tests" | while read options expect; do
if [ "$options" = "''" ]; then options=; fi
eval set -- "$options"
run_podman history "$@" $IMAGE
is "$output" "$expect" "podman history $options"
done
}
@test "podman history - custom format" {
run_podman history --format "{{.ID}}\t{{.ID}}" $IMAGE
od -c <<<$output
while IFS= read -r row; do
is "$row" ".* .*$"
done <<<$output
}
@test "podman history - json" {
# Sigh. Timestamp in .created can be '...Z' or '...-06:00'
tests="
id | [0-9a-f]\\\{64\\\}
created | [0-9-]\\\+T[0-9:.]\\\+[Z0-9:+-]\\\+
size | -\\\?[0-9]\\\+
"
run_podman history --format json $IMAGE
parse_table "$tests" | while read field expect; do
# HACK: we can't include '|' in the table
if [ "$field" = "id" ]; then expect="$expect\|<missing>";fi
# output is an array of dicts; check each one
count=$(echo "$output" | jq '. | length')
i=0
while [ $i -lt $count ]; do
actual=$(echo "$output" | jq -r ".[$i].$field")
is "$actual" "$expect\$" "jq .[$i].$field"
i=$(expr $i + 1)
done
done
}
@test "podman image history Created" {
# Values from image LIST
run_podman image list --format '{{.CreatedSince}}--{{.CreatedAt}}' $IMAGE
from_imagelist="$output"
assert "$from_imagelist" =~ "^[0-9].* ago--[0-9]+-[0-9]+-[0-9]+ [0-9:]+ " \
"CreatedSince and CreatedAt look reasonable"
# Values from image HISTORY
run_podman image history --format '{{.CreatedSince}}--{{.CreatedAt}}' $IMAGE
assert "${lines[0]}" == "$from_imagelist" \
"CreatedSince and CreatedAt from image history should == image list"
}
# vim: filetype=sh
|