-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path21-find.bats
More file actions
77 lines (58 loc) · 2.08 KB
/
21-find.bats
File metadata and controls
77 lines (58 loc) · 2.08 KB
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
#!/usr/bin/env bats
#
# 21- - cli tests
#
load app
setup(){
[ -d "$DEX_HOME/checkouts/find-test" ] || {
mkdir -p "$DEX_HOME/checkouts/find-test/dex-images"
fixture/cp "dex-images" "$DEX_HOME/checkouts/find-test/"
}
}
@test "find-repostr output is parsable with IFS='/:'" {
local repo
local image
local tag
IFS="/:" read repo image tag <<< "$($APP runfunc dex/get-repostr "extra/alpine:latest")"
[ "$repo" = "extra" ]
[ "$image" = "alpine" ]
[ "$tag" = "latest" ]
IFS="/:" read repo image tag <<< "$($APP runfunc dex/get-repostr "extra/")"
[ "$repo" = "extra" ]
[ "$image" = "" ]
[ "$tag" = "" ]
IFS="/:" read repo image tag <<< "$($APP runfunc dex/get-repostr "alpine")"
[ "$repo" = "" ]
[ "$image" = "alpine" ]
[ "$tag" = "" ]
IFS="/:" read repo image tag <<< "$($APP runfunc dex/get-repostr ":macos")"
[ "$repo" = "" ]
[ "$image" = "" ]
[ "$tag" = "macos" ]
}
@test "find-repostr respects default tags" {
[ "$($APP runfunc dex/get-repostr "alpine" "latest")" = "/alpine:latest" ]
}
@test "find-repostr will not default tag on unspecified images" {
[ "$($APP runfunc dex/get-repostr "extra/" "latest")" = "extra/:" ]
}
@test "find-dockerfiles returns available dockerfiles in repository checkouts" {
count=$(find $DEX_HOME/checkouts/find-test/dex-images | grep Dockerfile | wc -l)
run $APP runfunc dex/find-dockerfiles "find-test/"
[ ${#lines[@]} -eq $count ]
}
@test "find-dockerfiles respects filtering dockerfiles by repostr" {
count=$(find $DEX_HOME/checkouts/find-test/dex-images/alpine | grep Dockerfile | wc -l)
run $APP runfunc dex/find-dockerfiles "find-test/alpine"
[ ${#lines[@]} -eq $count ]
run $APP runfunc dex/find-dockerfiles "find-test/alpine:latest"
[ ${#lines[@]} -eq 1 ]
}
@test "find-repostr-from-dockerfile returns IFS parsable repostr" {
dockerfile=$($APP runfunc dex/find-dockerfiles "find-test/alpine:latest")
repostr=$($APP runfunc dex/get-repostr-from-dockerfile "$dockerfile")
IFS="/:" read repo image tag <<< "$repostr"
[ "$repo" = "find-test" ]
[ "$image" = "alpine" ]
[ "$tag" = "latest" ]
}