From e611bf2ac4a6d8f7623eb4db7107aa01a632c865 Mon Sep 17 00:00:00 2001 From: Malachi Soord Date: Tue, 8 Jun 2021 14:13:22 +0200 Subject: [PATCH 1/2] Add test foundations (#14) --- .github/workflows/go.yml | 2 +- Makefile | 3 +++ internal/utils/utils_test.go | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 internal/utils/utils_test.go diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index ef15743..f72cf25 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -25,4 +25,4 @@ jobs: run: make build - name: Test - run: go test -v ./... + run: make test diff --git a/Makefile b/Makefile index 8c9e222..4209eb3 100644 --- a/Makefile +++ b/Makefile @@ -24,3 +24,6 @@ build: clean: rm -rf ${BUILD_DIR} go clean + +test: + go test -tags=unit -timeout=600s -v ./... diff --git a/internal/utils/utils_test.go b/internal/utils/utils_test.go new file mode 100644 index 0000000..e09778e --- /dev/null +++ b/internal/utils/utils_test.go @@ -0,0 +1,18 @@ +// +build unit + +package utils + +import ( + "testing" + "time" +) + +func TestGetSQLiteFormattedDateTime(t *testing.T) { + datetime := time.Date(2021, time.Month(1), 01, 1, 30, 15, 0, time.UTC) + result := GetSQLiteFormattedDateTime(datetime) + + if result != "2021-01-01 01:30:15" { + t.Log("Expected 2021-01-01 01:30:15 but got ", result) + t.Fail() + } +} From 92ac9c2b03588a965d3146b311867f8bb21f9c17 Mon Sep 17 00:00:00 2001 From: Malachi Soord Date: Tue, 8 Jun 2021 22:40:53 +0200 Subject: [PATCH 2/2] Add coverage (#15) * Add coverage * Add codecov.yml --- .github/workflows/go.yml | 10 +++++----- Makefile | 3 +++ codecov.yml | 4 ++++ 3 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 codecov.yml diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index f72cf25..d8b2f24 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -12,17 +12,17 @@ jobs: name: Build runs-on: ubuntu-latest steps: - - name: Set up Go uses: actions/setup-go@v2 with: go-version: ^1.15 - - name: Check out code uses: actions/checkout@v2 - - name: Build run: make build - - name: Test - run: make test + run: make test-with-coverage + - uses: codecov/codecov-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: coverage.out diff --git a/Makefile b/Makefile index 4209eb3..53e3cb4 100644 --- a/Makefile +++ b/Makefile @@ -27,3 +27,6 @@ clean: test: go test -tags=unit -timeout=600s -v ./... + +test-with-coverage: + go test -tags=unit -timeout=600s -v ./... -coverprofile=coverage.out diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..f28b638 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,4 @@ +codecov: + require_ci_to_pass: no + +comment: false