-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_test.bats
84 lines (74 loc) · 2.04 KB
/
check_test.bats
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
#! /usr/bin/env bats
ignoring_error() {
"$@" 2>/dev/null
}
remove_whitespace() {
echo "$1" | tr -d " \n"
}
@test "checking" {
MAVEN_REPO="$(mktemp -d)"
mkdir -p "$MAVEN_REPO/repo/g/r/o/u/p/artifact"
cat >"$MAVEN_REPO/repo/g/r/o/u/p/artifact/maven-metadata.xml" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<metadata modelVersion="1.1.0">
<groupId>ignored</groupId>
<artifactId>ignored</artifactId>
<versioning>
<latest>ignored</latest>
<release>ignored</release>
<versions>
<version>1.9</version>
<version>1.10</version>
<version>1.11</version>
</versions>
<lastUpdated>ignored</lastUpdated>
</versioning>
</metadata>
EOF
run ignoring_error ./check <<EOF
{
"source": {
"repository":"file://$MAVEN_REPO/repo",
"group":"g.r.o.u.p",
"artifact":"artifact"
},
"version": { "version": "1.10" }
}
EOF
expected='[{"version": "1.10"}, {"version": "1.11"}]'
[[ $status -eq 0 ]]
[[ "$(remove_whitespace "$output")" == "$(remove_whitespace "$expected")" ]]
}
@test "checking for the first time" {
MAVEN_REPO="$(mktemp -d)"
mkdir -p "$MAVEN_REPO/repo/g/r/o/u/p/artifact"
cat >"$MAVEN_REPO/repo/g/r/o/u/p/artifact/maven-metadata.xml" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<metadata modelVersion="1.1.0">
<groupId>ignored</groupId>
<artifactId>ignored</artifactId>
<versioning>
<latest>ignored</latest>
<release>ignored</release>
<versions>
<version>1.9</version>
<version>1.10</version>
<version>1.11</version>
</versions>
<lastUpdated>ignored</lastUpdated>
</versioning>
</metadata>
EOF
run ignoring_error ./check <<EOF
{
"source": {
"repository":"file://$MAVEN_REPO/repo",
"group":"g.r.o.u.p",
"artifact":"artifact"
}
}
EOF
expected='[{"version": "1.11"}]'
[[ $status -eq 0 ]]
[[ "$(remove_whitespace "$output")" == "$(remove_whitespace "$expected")" ]]
}