Skip to content

Commit

Permalink
By default, test without Kind (#524)
Browse files Browse the repository at this point in the history
  • Loading branch information
genevieveluyt authored Feb 1, 2023
1 parent e89e66d commit d3ecd6b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ jobs:
- name: Go mod download and go tidy
run: make setup
- name: Run tests
env:
USE_KIND: "true"
run: make test
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ If you'd like to fix a bug, contribute a feature or just correct a typo, please
1. Add your forked repo as a fork: `git remote add fork https://github.com/you-are-awesome/kubeaudit`
1. Create your feature branch: `git checkout -b awesome-new-feature`
1. Install [Kind](https://kind.sigs.k8s.io/#installation-and-usage)
1. Run the tests to see everything is working as expected: `make test` (to run tests without Kind: `USE_KIND=false make test`)
1. Run the tests to see everything is working as expected: `USE_KIND=true make test` (to run tests without Kind: `make test`)
1. Commit your changes: `git commit -am 'Adds awesome feature'`
1. Push to the branch: `git push fork`
1. Sign the [Contributor License Agreement](https://cla.shopify.com/)
Expand Down
2 changes: 1 addition & 1 deletion internal/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func GetAllFileNames(t *testing.T, directory string) []string {

// UseKind returns true if tests which utilize Kind should run
func UseKind() bool {
return os.Getenv("USE_KIND") != "false"
return os.Getenv("USE_KIND") == "true"
}

func ApplyManifest(t *testing.T, manifestPath, namespace string) {
Expand Down
3 changes: 1 addition & 2 deletions kubeaudit_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package kubeaudit_test

import (
"os"
"testing"

"github.com/Shopify/kubeaudit"
Expand Down Expand Up @@ -29,7 +28,7 @@ func TestNew(t *testing.T) {
}

func TestAuditLocal(t *testing.T) {
if os.Getenv("USE_KIND") == "false" {
if !test.UseKind() {
return
}

Expand Down
4 changes: 2 additions & 2 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ set -e
echo "Starting tests. This may take a while..."

function finish {
if [ "$USE_KIND" != "false" ] ; then
if [ "$USE_KIND" == "true" ] ; then
make test-teardown
fi
}
trap finish EXIT

if [ "$USE_KIND" != "false" ] ; then
if [ "$USE_KIND" == "true" ] ; then
make test-setup
fi

Expand Down

0 comments on commit d3ecd6b

Please sign in to comment.