From aa464cb01a6ca547b6cc0207b2724090b289b35e Mon Sep 17 00:00:00 2001
From: Neil-Jocelyn Schark <neil.schark@h-da.de>
Date: Thu, 14 Mar 2024 15:41:26 +0000
Subject: [PATCH] test unit-tests

---
 .gitlab-ci.yml | 18 ++++++++++++++++++
 Makefile       |  3 +--
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 417d99be..a2516005 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -63,6 +63,24 @@ code-vulnerability:
         - govulncheck ./...
     needs: []
 
+unit-tests:
+    image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/golang:$GOLANG_VERSION
+    stage: test
+    before_script:
+        - apt update && apt install -y make
+    script:
+        - make test
+        - go tool cover -func=coverage.out
+        - gocover-cobertura < coverage.out > coverage.xml
+    artifacts:
+        expire_in: 1 week
+        when: always
+        reports:
+            junit: report.xml
+            coverage_report:
+                coverage_format: cobertura
+                path: coverage.xml
+    needs: []
 
 integration-test-kms:
     image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/golang:$GOLANG_VERSION-bookworm
diff --git a/Makefile b/Makefile
index c552a998..3455c933 100644
--- a/Makefile
+++ b/Makefile
@@ -39,8 +39,7 @@ lint-fix: install-tools
 	./$(TOOLS_DIR)/golangci-lint run --config .golangci.yml --fix | jq
 
 test:
-	go test -v ./ekms/...
-	go test -v ./quantumlayer/...
+	go test -coverprofile=coverage.out -v ./ekms/... ./quantumlayer/...
 
 build-ekms: pre
 	CGO_ENABLED=0 $(GOBUILD) -o $(BUILD_ARTIFACTS_PATH)/ekms ./ekms/main.go
-- 
GitLab