Skip to content

Commit 54c3c1d

Browse files
khruChemaclassantonio-gg-dev
authored
test: add bashunit (#64)
* chore: add bashunit to the repo * chore: created folder for test and check that bashunit works * chore: snapshot for test_should_ignore_files_with_glob * chore: add pipeline * chore: snapshot update * git ignore bashunit, rather install it as vendor * chore: code style * chore: fix installed bashunit version --------- Co-authored-by: Chemaclass <[email protected]> Co-authored-by: katarn <[email protected]>
1 parent d269449 commit 54c3c1d

File tree

8 files changed

+129
-0
lines changed

8 files changed

+129
-0
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DEFAULT_PATH=tests

.github/CONTRIBUTIONS.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Testing
2+
3+
Tests written in [bashunit](https://bashunit.typeddevs.com/).
4+
5+
Install vendor dependencies:
6+
```bash
7+
./install-dependencies.sh
8+
```
9+
10+
Run all tests:
11+
```bash
12+
./lib/bashunit tests
13+
```

.github/workflows/test.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
on:
2+
pull_request:
3+
push:
4+
branches:
5+
- main
6+
7+
name: Tests
8+
jobs:
9+
tests:
10+
name: "Run tests"
11+
runs-on: 'ubuntu-latest'
12+
steps:
13+
- uses: actions/checkout@v3
14+
15+
- name: "Install dependencies"
16+
run: ./install-dependencies.sh
17+
18+
- name: "Tests"
19+
run: ./lib/bashunit

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.idea/
2+
3+
lib/bashunit

install-dependencies.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
## bashunit
4+
curl -s https://bashunit.typeddevs.com/install.sh | bash -s -- lib 0.10.0
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
[
2+
{
3+
"filename": ".editorconfig",
4+
"additions": 9,
5+
"deletions": 0,
6+
"changes": 9
7+
},
8+
{
9+
"filename": ".github/workflows/ci.yml",
10+
"additions": 17,
11+
"deletions": 0,
12+
"changes": 17
13+
},
14+
{
15+
"filename": "asdasdasd.lock",
16+
"additions": 1188,
17+
"deletions": 0,
18+
"changes": 1188
19+
},
20+
{
21+
"filename": "entrypoint.sh",
22+
"additions": 4,
23+
"deletions": 4,
24+
"changes": 8
25+
},
26+
{
27+
"filename": "src/ensure.sh",
28+
"additions": 4,
29+
"deletions": 4,
30+
"changes": 8
31+
},
32+
{
33+
"filename": "src/github.sh",
34+
"additions": 89,
35+
"deletions": 76,
36+
"changes": 165
37+
},
38+
{
39+
"filename": "src/github_actions.sh",
40+
"additions": 1,
41+
"deletions": 1,
42+
"changes": 2
43+
},
44+
{
45+
"filename": "src/inner.lock",
46+
"additions": 1188,
47+
"deletions": 0,
48+
"changes": 1188
49+
},
50+
{
51+
"filename": "src/labeler.sh",
52+
"additions": 48,
53+
"deletions": 48,
54+
"changes": 96
55+
},
56+
{
57+
"filename": "src/log.sh",
58+
"additions": 17,
59+
"deletions": 0,
60+
"changes": 17
61+
},
62+
{
63+
"filename": "src/main.sh",
64+
"additions": 34,
65+
"deletions": 23,
66+
"changes": 57
67+
},
68+
{
69+
"filename": "src/misc.sh",
70+
"additions": 10,
71+
"deletions": 14,
72+
"changes": 24
73+
}
74+
]

tests/github_test.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
function set_up() {
4+
source ./src/misc.sh
5+
source ./src/github.sh
6+
}
7+
8+
function test_should_ignore_files_with_glob() {
9+
local -r pr_number=123
10+
local -r files_to_ignore=("*.lock" ".editorconfig")
11+
mock curl cat ./tests/fixtures/test_should_ignore_files_with_regex_response
12+
13+
assert_match_snapshot "$(github::calculate_total_modifications "$pr_number" "${files_to_ignore[*]}")"
14+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
394

0 commit comments

Comments
 (0)