Skip to content

Commit 35cb94b

Browse files
committed
tests: Refactor scripts
1 parent 1f5326e commit 35cb94b

File tree

9 files changed

+382
-319
lines changed

9 files changed

+382
-319
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ before_script:
3535
- sed -i "s/ssh_server:.*/ssh_server:localhost/" $HOME/.git-simpleserver/config.yaml
3636

3737
script:
38-
- ./test.sh --i-know-what-im-doing
38+
- ./tests/run.sh --i-know-what-im-doing

test.sh

Lines changed: 0 additions & 318 deletions
This file was deleted.

tests/01-repo.test

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/sh
2+
3+
. "$TESTSDIR/common-repo.sh"
4+
5+
INVALID_REPO_NAME_ERROR_MSG="Error! Disallowed characters in repo name. Allowed: a-z, A-Z, 0-9, _, -"
6+
7+
# Test repo listing & creation
8+
repos_list_count_must_equal "0"
9+
repo_create "test" # should not fail
10+
repos_list_count_must_equal "1"
11+
repo_create "test2" # should not fail
12+
repos_list_count_must_equal "2"
13+
repo_create "test3" # should not fail
14+
repos_list_count_must_equal "3"
15+
repo_create "test2" "Error! Repo 'test2' already exists" # create test a second time, should fail
16+
repos_list_count_must_equal "3"
17+
repo_create "my test" "$INVALID_REPO_NAME_ERROR_MSG"
18+
repo_create "my.test" "$INVALID_REPO_NAME_ERROR_MSG"
19+
repo_create "my–test" "$INVALID_REPO_NAME_ERROR_MSG" # endash
20+
repo_create 'my\\test' "$INVALID_REPO_NAME_ERROR_MSG"
21+
repo_create 'lal\\\\a' "$INVALID_REPO_NAME_ERROR_MSG"
22+
repo_create "my+test" "$INVALID_REPO_NAME_ERROR_MSG"
23+
repo_create "my/test" "$INVALID_REPO_NAME_ERROR_MSG"
24+
repos_list_count_must_equal "3"
25+
26+
# Test repo deletion
27+
repo_delete "test"
28+
repos_list_count_must_equal "2"
29+
repo_delete "test" "Error! Repo 'test' does not exist"
30+
repos_list_count_must_equal "2"
31+
repo_delete "my/test" "$INVALID_REPO_NAME_ERROR_MSG" # just to make sure slash never works
32+
repos_list_count_must_equal "2"
33+
34+
# Test repo info of non-existing repo
35+
repo_info "test-non-existing" "Error! Repo 'test-non-existing' does not exist"
36+
37+
# Test repo info of existing repo
38+
repo_info "test2" "Users with read access:
39+
$USER_NAME
40+
Users with write access:
41+
$USER_NAME"
42+
repo_access "test2" "-rw" "blubb" "User 'blubb' now has read access
43+
User 'blubb' now has write access"
44+
repo_info "test2" "Users with read access:
45+
$USER_NAME
46+
blubb
47+
Users with write access:
48+
$USER_NAME
49+
blubb"
50+
repo_access "test2" "-r" "blubb" "User 'blubb' already has read access
51+
User 'blubb' no longer has write access"
52+
repo_info "test2" "Users with read access:
53+
$USER_NAME
54+
blubb
55+
Users with write access:
56+
$USER_NAME"
57+
repo_access "test2" "-rm" "blubb" "User 'blubb' no longer has read access
58+
User 'blubb' no longer has write access"
59+
repo_info "test2" "Users with read access:
60+
$USER_NAME
61+
Users with write access:
62+
$USER_NAME"

0 commit comments

Comments
 (0)