From fbdbdbe5e713e07c994b8a88dabedb51438c588d Mon Sep 17 00:00:00 2001 From: Don Khan Date: Tue, 13 Aug 2024 15:53:04 -0400 Subject: [PATCH 1/3] Restructure of unit tests. --- Makefile | 6 +++--- .../unit_main_test.go => bdd-test/bdd_main_test.go} | 4 ++-- test/{unit-test/unit_test.go => bdd-test/bdd_test.go} | 2 +- test/bdd-test/c.out | 1 + .../features/unit.feature => bdd-test/features/bdd.feature} | 0 test/{unit-test => bdd-test}/run.sh | 0 6 files changed, 7 insertions(+), 6 deletions(-) rename test/{unit-test/unit_main_test.go => bdd-test/bdd_main_test.go} (97%) rename test/{unit-test/unit_test.go => bdd-test/bdd_test.go} (99%) create mode 100644 test/bdd-test/c.out rename test/{unit-test/features/unit.feature => bdd-test/features/bdd.feature} (100%) rename test/{unit-test => bdd-test}/run.sh (100%) diff --git a/Makefile b/Makefile index 6865f902..e00f6f1c 100644 --- a/Makefile +++ b/Makefile @@ -22,9 +22,9 @@ go-build: clean integration-test: ( cd test/integration-test; sh run.sh ) -# Unit tests using Godog. Populate env.sh with the hardware parameters -unit-test: - ( cd test/unit-test; sh run.sh ) +# BDD tests using Godog. Populate env.sh with the hardware parameters +bdd-test: + ( cd test/bdd-test; sh run.sh ) .PHONY: download-csm-common download-csm-common: diff --git a/test/unit-test/unit_main_test.go b/test/bdd-test/bdd_main_test.go similarity index 97% rename from test/unit-test/unit_main_test.go rename to test/bdd-test/bdd_main_test.go index d2fe7696..2a2d78bc 100644 --- a/test/unit-test/unit_main_test.go +++ b/test/bdd-test/bdd_main_test.go @@ -1,5 +1,5 @@ /* - Copyright © 2019 Dell Inc. or its subsidiaries. All Rights Reserved. + Copyright (c) 2019-2024 Dell Inc. or its subsidiaries. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -12,7 +12,7 @@ limitations under the License. */ -package unit_test +package bdd_test import ( "context" diff --git a/test/unit-test/unit_test.go b/test/bdd-test/bdd_test.go similarity index 99% rename from test/unit-test/unit_test.go rename to test/bdd-test/bdd_test.go index cc0fee2a..99427395 100644 --- a/test/unit-test/unit_test.go +++ b/test/bdd-test/bdd_test.go @@ -12,7 +12,7 @@ limitations under the License. */ -package unit_test +package bdd_test import ( "context" diff --git a/test/bdd-test/c.out b/test/bdd-test/c.out new file mode 100644 index 00000000..5f02b111 --- /dev/null +++ b/test/bdd-test/c.out @@ -0,0 +1 @@ +mode: set diff --git a/test/unit-test/features/unit.feature b/test/bdd-test/features/bdd.feature similarity index 100% rename from test/unit-test/features/unit.feature rename to test/bdd-test/features/bdd.feature diff --git a/test/unit-test/run.sh b/test/bdd-test/run.sh similarity index 100% rename from test/unit-test/run.sh rename to test/bdd-test/run.sh From a242fc0200b16e5e60d4d0142cd86e2a5d3b4bdf Mon Sep 17 00:00:00 2001 From: Don Khan Date: Tue, 13 Aug 2024 15:55:32 -0400 Subject: [PATCH 2/3] Testing hook --- hooks/pre-commit | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 hooks/pre-commit diff --git a/hooks/pre-commit b/hooks/pre-commit old mode 100644 new mode 100755 From 38e13f6fb529cbc75e54e574064a53c053c8b66d Mon Sep 17 00:00:00 2001 From: Don Khan Date: Tue, 13 Aug 2024 17:17:39 -0400 Subject: [PATCH 3/3] Get some unit tests to run with success. --- .github/workflows/actions.yaml | 12 ++++++++++++ Makefile | 4 ++++ dell-csi-helm-installer/README.md | 7 +++---- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/actions.yaml b/.github/workflows/actions.yaml index 620ae95a..dc5912ef 100644 --- a/.github/workflows/actions.yaml +++ b/.github/workflows/actions.yaml @@ -15,6 +15,18 @@ jobs: uses: dell/common-github-actions/go-code-formatter-linter-vetter@main with: directories: ./... + test: + name: Run Go unit tests and check package coverage + runs-on: ubuntu-latest + steps: + - name: Checkout csi-unity + uses: actions/checkout@v4 + - name: Run unit tests and check package coverage + uses: dell/common-github-actions/go-code-tester@main + with: + threshold: 20 + test-folder: "./service/utils" + race-detector: "true" go_security_scan: name: Run gosec runs-on: ubuntu-latest diff --git a/Makefile b/Makefile index e00f6f1c..9ed84791 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,10 @@ go-build: clean cd core && go generate go build . +# Only unit testing utils for now. More work to do but need to start somewhere. +unit-test: + ( cd service/utils; go clean -cache; go test -v -coverprofile=c.out ./... ) + # Integration tests using Godog. Populate env.sh with the hardware parameters integration-test: ( cd test/integration-test; sh run.sh ) diff --git a/dell-csi-helm-installer/README.md b/dell-csi-helm-installer/README.md index 460516b3..a5a39d90 100644 --- a/dell-csi-helm-installer/README.md +++ b/dell-csi-helm-installer/README.md @@ -1,6 +1,6 @@