forked from get-gah/gah
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path02_github_api_functions.bats
More file actions
56 lines (42 loc) · 1.39 KB
/
02_github_api_functions.bats
File metadata and controls
56 lines (42 loc) · 1.39 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
load "test_helper/bats-support/load"
load "test_helper/bats-assert/load"
load "test_helper/bats-mock/stub"
load "test_helper/common"
load "$DIR/gah"
setup() {
common_setup
}
teardown() {
common_teardown
if [[ -n "$TEST_TEMP_DIR" && -d "$TEST_TEMP_DIR" ]]; then
rm -rf "$TEST_TEMP_DIR"
TEST_TEMP_DIR=""
fi
unstub uname || true
unstub curl || true
unstub wget || true
}
@test "get_fetch_release_info_url should print the correct URL if no version is provided" {
run get_fetch_release_info_url "abc/def" ""
assert_success
assert_output "https://api.github.com/repos/abc/def/releases/latest"
}
@test "get_fetch_release_info_url should print the correct URL if a version is latest" {
run get_fetch_release_info_url "abc/def" "latest"
assert_success
assert_output "https://api.github.com/repos/abc/def/releases/latest"
}
@test "get_fetch_release_info_url should print the correct URL if a version is provided" {
run get_fetch_release_info_url "abc/def" "v1.2.3"
assert_success
assert_output "https://api.github.com/repos/abc/def/releases/tags/v1.2.3"
}
@test "fetch_release_info should save the release info to a file" {
stub curl "-s * : cat '$DIR/test/fixtures/releases/argocd/release.json'"
stub wget "-q * : cat '$DIR/test/fixtures/releases/argocd/release.json'"
TEST_TEMP_DIR=$(mktemp -d)
cd "$TEST_TEMP_DIR"
run fetch_release_info
assert_success
assert [ -f "release.json" ]
}