Skip to content

Commit

Permalink
bats test setup with some initial tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kristofferlind committed Nov 6, 2022
1 parent 9c737eb commit 6a64e79
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 16 deletions.
16 changes: 0 additions & 16 deletions .gometalinter.json

This file was deleted.

19 changes: 19 additions & 0 deletions test/build.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bats

@test "knega without arguments should display usage" {
run $KNEGA
[ "$status" -eq 2 ]
[[ "$output" = *"Usage: knega changed"* ]]
}

@test "knega changed build should build everything when starting from scratch" {
run $KNEGA changed build
[[ "$output" = *"example-1"*"Rebuild required"* ]]
[[ "$output" = *"example-2"*"Rebuild required"* ]]
}

@test "knega changed build should build nothing on second run" {
run $KNEGA changed build
[[ "$output" = *"example-1"*"Artifacts found"* ]]
[[ "$output" = *"example-2"*"Artifacts found"* ]]
}
7 changes: 7 additions & 0 deletions test/setup_suite.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
setup_suite() {
KNEGA=${KNEGA:-knega}
CURRENT_DIRECTORY=$(pwd)
SCRIPT_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
CONFIGURATION_DIRECTORY=$SCRIPT_DIRECTORY/../examples/full
cd $CONFIGURATION_DIRECTORY
}
7 changes: 7 additions & 0 deletions test/test.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bats

@test "knega changed test should only execute where action test defined" {
run $KNEGA changed test
[[ "$output" = *"test action executed in test-only-1"* ]]
[[ "$output" != *"example-1"* ]]
}

0 comments on commit 6a64e79

Please sign in to comment.