diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml index 0bbabdd..45d7e0d 100644 --- a/.github/workflows/coverage.yaml +++ b/.github/workflows/coverage.yaml @@ -16,7 +16,7 @@ jobs: go-version: stable - name: Calculate coverage run: | - go test -v -covermode=count -coverprofile=cover.out.raw -coverpkg=./... ./... + go test -v -covermode=atomic -coverprofile=cover.out.raw -coverpkg=./... ./... # remove mocks from coverage calculation grep -v mock_ cover.out.raw > cover.out - name: Generage coverage badge diff --git a/.gitignore b/.gitignore index 9b1c8b1..dc0c8d2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /dist +/cover.out diff --git a/Makefile b/Makefile index c5dc744..64d11a6 100644 --- a/Makefile +++ b/Makefile @@ -20,3 +20,8 @@ build: .PHONY: fuzz fuzz: mod-tidy generate go test -fuzz='^Fuzz' -fuzztime=10s -v ./internal/server + +.PHONY: cover +cover: mod-tidy generate + go test -v -covermode=atomic -coverprofile=cover.out -coverpkg=./... ./... + go tool cover -html=cover.out diff --git a/README.md b/README.md index 43d5751..53caa7f 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ Then push some code to main: git checkout --orphan badges git rm -rf . rm -f .gitignore - echo 'This branch exists only to contains the coverage badge in the README on `main`.' > README.md + echo 'This branch exists only to store the coverage badge in the README on `main`.' > README.md git add README.md git commit -m 'chore: initialize the badges branch' git push origin badges @@ -101,7 +101,7 @@ Configure the repository: 1. Go to repository Settings > Rules > Rulesets, and import the `protect-default-branch.json` ruleset. -1. That's it. +That's it. ## How to contribute diff --git a/internal/server/serve_test.go b/internal/server/serve_test.go index 7de175f..0fb934f 100644 --- a/internal/server/serve_test.go +++ b/internal/server/serve_test.go @@ -47,6 +47,10 @@ func TestGreet(t *testing.T) { expect: "time travel detected", expectError: true, }, + "late birthday": { + input: []string{"Foo", "2000-12-22"}, + expect: "Hello Foo, happy belated birthday for 355 days ago.", + }, } for name, tc := range testCases { t.Run(name, func(tt *testing.T) {