Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add bashunit #64

Merged
merged 8 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DEFAULT_PATH=tests
13 changes: 13 additions & 0 deletions .github/CONTRIBUTIONS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Testing

Tests written in [bashunit](https://bashunit.typeddevs.com/).

Install vendor dependencies:
```bash
./install-dependencies.sh
```

Run all tests:
```bash
./lib/bashunit tests
```
19 changes: 19 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
on:
pull_request:
push:
branches:
- main

name: Tests
jobs:
tests:
name: "Run tests"
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v3

- name: "Install dependencies"
run: ./install-dependencies.sh

- name: "Tests"
run: ./lib/bashunit
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea/

lib/bashunit
4 changes: 4 additions & 0 deletions install-dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

## bashunit
curl -s https://bashunit.typeddevs.com/install.sh | bash -s -- lib 0.10.0
74 changes: 74 additions & 0 deletions tests/fixtures/test_should_ignore_files_with_regex_response
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
[
{
"filename": ".editorconfig",
"additions": 9,
"deletions": 0,
"changes": 9
},
{
"filename": ".github/workflows/ci.yml",
"additions": 17,
"deletions": 0,
"changes": 17
},
{
"filename": "asdasdasd.lock",
"additions": 1188,
"deletions": 0,
"changes": 1188
},
{
"filename": "entrypoint.sh",
"additions": 4,
"deletions": 4,
"changes": 8
},
{
"filename": "src/ensure.sh",
"additions": 4,
"deletions": 4,
"changes": 8
},
{
"filename": "src/github.sh",
"additions": 89,
"deletions": 76,
"changes": 165
},
{
"filename": "src/github_actions.sh",
"additions": 1,
"deletions": 1,
"changes": 2
},
{
"filename": "src/inner.lock",
"additions": 1188,
"deletions": 0,
"changes": 1188
},
{
"filename": "src/labeler.sh",
"additions": 48,
"deletions": 48,
"changes": 96
},
{
"filename": "src/log.sh",
"additions": 17,
"deletions": 0,
"changes": 17
},
{
"filename": "src/main.sh",
"additions": 34,
"deletions": 23,
"changes": 57
},
{
"filename": "src/misc.sh",
"additions": 10,
"deletions": 14,
"changes": 24
}
]
14 changes: 14 additions & 0 deletions tests/github_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

function set_up() {
source ./src/misc.sh
source ./src/github.sh
}

function test_should_ignore_files_with_glob() {
local -r pr_number=123
local -r files_to_ignore=("*.lock" ".editorconfig")
mock curl cat ./tests/fixtures/test_should_ignore_files_with_regex_response

assert_match_snapshot "$(github::calculate_total_modifications "$pr_number" "${files_to_ignore[*]}")"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
394