Skip to content

Commit

Permalink
More cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
szabolcs-horvath committed Dec 30, 2024
1 parent e0b1edb commit 3ee7509
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
PORT="6969"
DB_FILE="sqlite/nutrition-tracker-test.db"
DB_FILE="it/nutrition-tracker-test.db"
2 changes: 1 addition & 1 deletion .github/.testcoverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# unit tests and integration tests separately, you can combine all those
# profiles into one. In this case, the profile should have a comma-separated list
# of profile files, e.g., 'cover_unit.out,cover_integration.out'.
profile: coverage/unit-coverage.out,coverage/it-coverage.out
profile: coverage/ut-coverage.out,coverage/it-coverage.out

# (optional; but recommended to set)
# When specified reported file paths will not contain local prefix in the output.
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/go-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
run: make build

- name: Generate test coverage from unit tests
run: make unit-test
run: make ut

- name: Generate test coverage from integration tests
run: make integration-test
run: make it

- name: Check test coverage
uses: vladopajic/go-test-coverage@v2
Expand Down
26 changes: 13 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SQLITE_DB_FILE ?= sqlite/nutrition-tracker.db
IT_SQLITE_DB_FILE ?= sqlite/nutrition-tracker-test.db
IT_SQLITE_DB_FILE ?= it/nutrition-tracker-test.db
SQLITE_MIGRATIONS_DIR ?= sqlite/migrations
SQLC_VERSION ?= v1.27.0
GOLANG_MIGRATE_VERSION ?= v4.18.1
Expand Down Expand Up @@ -29,31 +29,31 @@ generate:
clean:
rm -rf generated out

unit-test: sqlc
rm -f $(GOCOVERDIR)/unit-coverage.out
ut: sqlc
rm -f $(GOCOVERDIR)/ut-coverage.out
mkdir -p $(GOCOVERDIR)
go test ./... -v -coverprofile=$(GOCOVERDIR)/unit-coverage.out -covermode=atomic -coverpkg=./...
go test ./... -v -coverprofile=$(GOCOVERDIR)/ut-coverage.out -covermode=atomic -coverpkg=./...

integration-test: sqlc init-test-db
it: sqlc init-test-db
rm -rf $(GOCOVERDIR)/it-coverage
mkdir -p $(GOCOVERDIR)/it-coverage
go build -o out/nutrition-tracker-integration-test -mod=readonly -covermode=atomic
integration-test/integration-test.sh out/nutrition-tracker-integration-test $(GOCOVERDIR)/it-coverage
go build -o out/nutrition-tracker-it -mod=readonly -covermode=atomic
it/integration-test.sh out/nutrition-tracker-it $(GOCOVERDIR)/it-coverage
go tool covdata textfmt -i=$(GOCOVERDIR)/it-coverage -o=$(GOCOVERDIR)/it-coverage.out

init-test-db:
rm -f $(IT_SQLITE_DB_FILE)
make migrate-up-file SPECIFIED_DB_FILE=$(IT_SQLITE_DB_FILE)
sqlite3 $(IT_SQLITE_DB_FILE) < sqlite/seed_test.sql
sqlite3 $(IT_SQLITE_DB_FILE) < it/seed_test.sql

coverage: unit-test integration-test
go run ./.github/merge-coverprofiles.go $(GOCOVERDIR)/merged-coverage.out $(GOCOVERDIR)/unit-coverage.out $(GOCOVERDIR)/it-coverage.out
coverage: ut it
go run ./.github/merge-coverprofiles.go $(GOCOVERDIR)/merged-coverage.out $(GOCOVERDIR)/ut-coverage.out $(GOCOVERDIR)/it-coverage.out
go tool cover -html=$(GOCOVERDIR)/merged-coverage.out

coverage-unit: unit-test
go tool cover -html=$(GOCOVERDIR)/unit-coverage.out
coverage-ut: ut
go tool cover -html=$(GOCOVERDIR)/ut-coverage.out

coverage-it: integration-test
coverage-it: it
go tool cover -html=$(GOCOVERDIR)/it-coverage.out

create-migration:
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion repository/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
var templates *template.Template

func init() {
templates = template.Must(template.New("templates").Funcs(util.TemplateFuncs()).Funcs(TemplateFuncs()).ParseGlob("templates/*.gohtml"))
templates = template.Must(template.New("templates").Funcs(util.TemplateFuncs()).Funcs(TemplateFuncs()).ParseGlob("web/templates/*.gohtml"))
}

func Render(w io.Writer, name string, data map[string]any) error {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 3ee7509

Please sign in to comment.