-
Notifications
You must be signed in to change notification settings - Fork 0
/
in_test.bats
92 lines (75 loc) · 2.46 KB
/
in_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
85
86
87
88
89
90
91
92
#! /usr/bin/env bats
ignoring_error() {
"$@" 2>/dev/null
}
remove_whitespace() {
echo "$1" | tr -d " \n"
}
@test "getting the default artifact" {
MAVEN_REPO="$(mktemp -d)"
OUTPUT_DIR="$(mktemp -d)"
mkdir -p "$MAVEN_REPO/repo/g/r/o/u/p/artifact/1.10"
echo "this is a jar" > "$MAVEN_REPO/repo/g/r/o/u/p/artifact/1.10/artifact-1.10.jar"
run ignoring_error ./in "$OUTPUT_DIR" <<EOF
{
"source": {
"repository":"file://$MAVEN_REPO/repo",
"group":"g.r.o.u.p",
"artifact":"artifact"
},
"version": { "version": "1.10" }
}
EOF
expected='{"version": {"version": "1.10"}}'
echo "output=$output" >&2
[[ $status -eq 0 ]]
[[ "$(remove_whitespace "$output")" == "$(remove_whitespace "$expected")" ]]
[[ -f "$OUTPUT_DIR/artifact-1.10.jar" ]]
[[ "$(cat "$OUTPUT_DIR/artifact-1.10.jar")" == "this is a jar" ]]
}
@test "getting an artifact with a classifer" {
MAVEN_REPO="$(mktemp -d)"
OUTPUT_DIR="$(mktemp -d)"
mkdir -p "$MAVEN_REPO/repo/g/r/o/u/p/artifact/1.10"
echo "this is a source jar" > "$MAVEN_REPO/repo/g/r/o/u/p/artifact/1.10/artifact-1.10-sources.jar"
run ignoring_error ./in "$OUTPUT_DIR" <<EOF
{
"source": {
"repository":"file://$MAVEN_REPO/repo",
"group":"g.r.o.u.p",
"artifact":"artifact",
"classifier":"sources"
},
"version": { "version": "1.10" }
}
EOF
expected='{"version": {"version": "1.10"}}'
echo "output=$output" >&2
[[ $status -eq 0 ]]
[[ "$(remove_whitespace "$output")" == "$(remove_whitespace "$expected")" ]]
[[ -f "$OUTPUT_DIR/artifact-1.10-sources.jar" ]]
[[ "$(cat "$OUTPUT_DIR/artifact-1.10-sources.jar")" == "this is a source jar" ]]
}
@test "getting an artifact with specific packaging" {
MAVEN_REPO="$(mktemp -d)"
OUTPUT_DIR="$(mktemp -d)"
mkdir -p "$MAVEN_REPO/repo/g/r/o/u/p/artifact/1.10"
echo "this is a POM" > "$MAVEN_REPO/repo/g/r/o/u/p/artifact/1.10/artifact-1.10.pom"
run ignoring_error ./in "$OUTPUT_DIR" <<EOF
{
"source": {
"repository":"file://$MAVEN_REPO/repo",
"group":"g.r.o.u.p",
"artifact":"artifact",
"packaging":"pom"
},
"version": { "version": "1.10" }
}
EOF
expected='{"version": {"version": "1.10"}}'
echo "output=$output" >&2
[[ $status -eq 0 ]]
[[ "$(remove_whitespace "$output")" == "$(remove_whitespace "$expected")" ]]
[[ -f "$OUTPUT_DIR/artifact-1.10.pom" ]]
[[ "$(cat "$OUTPUT_DIR/artifact-1.10.pom")" == "this is a POM" ]]
}