Skip to content

Conversation

@yulmwu
Copy link
Member

@yulmwu yulmwu commented Jan 29, 2026

Refs: #4

> go test -v -race -cover -count=1 ./internal/db ./internal/repo
2026/01/29 11:58:24 github.com/testcontainers/testcontainers-go - Connected to docker: 
  Server Version: 28.2.2
  API Version: 1.50
  Operating System: Docker Desktop
  Total Memory: 3919 MB
  Labels:
    com.docker.desktop.address=unix:///Users/user/Library/Containers/com.docker.docker/Data/docker-cli.sock
  Testcontainers for Go Version: v0.40.0
  Resolved Docker Host: unix:///var/run/docker.sock
  Resolved Docker Socket Path: /var/run/docker.sock
  Test SessionID: f045ce4866d7bf91ddd769c944e698a278b2fea035acfb8644aa2c024b405c41
  Test ProcessID: 4fa51f5a-53c0-41d4-a7c5-ea1ee140542f
2026/01/29 11:58:24 🐳 Creating container for image postgres:16-alpine
2026/01/29 11:58:24 🐳 Creating container for image testcontainers/ryuk:0.13.0
2026/01/29 11:58:24 ✅ Container created: 7ff4181fa9fa
2026/01/29 11:58:24 🐳 Starting container: 7ff4181fa9fa
2026/01/29 11:58:24 ✅ Container started: 7ff4181fa9fa
2026/01/29 11:58:24 ⏳ Waiting for container id 7ff4181fa9fa image: testcontainers/ryuk:0.13.0. Waiting for: port 8080/tcp to be listening
2026/01/29 11:58:24 Shell not found in container
2026/01/29 11:58:24 🔔 Container is ready: 7ff4181fa9fa
2026/01/29 11:58:24 ✅ Container created: f618361d543e
2026/01/29 11:58:24 🐳 Starting container: f618361d543e
2026/01/29 11:58:25 ✅ Container started: f618361d543e
2026/01/29 11:58:25 ⏳ Waiting for container id f618361d543e image: postgres:16-alpine. Waiting for: port 5432/tcp to be listening
2026/01/29 11:58:26 🔔 Container is ready: f618361d543e
=== RUN   TestIsUniqueViolation
--- PASS: TestIsUniqueViolation (0.00s)
=== RUN   TestNewAndAutoMigrate
--- PASS: TestNewAndAutoMigrate (0.06s)
=== RUN   TestEnsureColumnsAndIndexes
--- PASS: TestEnsureColumnsAndIndexes (0.01s)
=== RUN   TestCreateTables
--- PASS: TestCreateTables (0.00s)
PASS
coverage: 79.5% of statements
2026/01/29 11:58:26 🐳 Stopping container: f618361d543e
2026/01/29 11:58:26 ✅ Container stopped: f618361d543e
2026/01/29 11:58:26 🐳 Terminating container: f618361d543e
2026/01/29 11:58:26 🚫 Container terminated: f618361d543e
ok      smctf/internal/db       3.700s  coverage: 79.5% of statements
2026/01/29 11:58:24 github.com/testcontainers/testcontainers-go - Connected to docker: 
  Server Version: 28.2.2
  API Version: 1.50
  Operating System: Docker Desktop
  Total Memory: 3919 MB
  Labels:
    com.docker.desktop.address=unix:///Users/user/Library/Containers/com.docker.docker/Data/docker-cli.sock
  Testcontainers for Go Version: v0.40.0
  Resolved Docker Host: unix:///var/run/docker.sock
  Resolved Docker Socket Path: /var/run/docker.sock
  Test SessionID: f045ce4866d7bf91ddd769c944e698a278b2fea035acfb8644aa2c024b405c41
  Test ProcessID: 5f1e912c-9a02-4238-9d74-faef2e470081
2026/01/29 11:58:24 🐳 Creating container for image postgres:16-alpine
2026/01/29 11:58:24 ⏳ Waiting for Reaper "7ff4181f" to be ready
2026/01/29 11:58:24 🔥 Reaper obtained from Docker for this test session 7ff4181f
2026/01/29 11:58:24 ✅ Container created: 71951f01d608
2026/01/29 11:58:24 🐳 Starting container: 71951f01d608
2026/01/29 11:58:25 ✅ Container started: 71951f01d608
2026/01/29 11:58:25 ⏳ Waiting for container id 71951f01d608 image: postgres:16-alpine. Waiting for: port 5432/tcp to be listening
2026/01/29 11:58:26 🔔 Container is ready: 71951f01d608
=== RUN   TestChallengeRepoCRUD
--- PASS: TestChallengeRepoCRUD (0.02s)
=== RUN   TestChallengeRepoNotFound
--- PASS: TestChallengeRepoNotFound (0.02s)
=== RUN   TestWrapError
--- PASS: TestWrapError (0.00s)
=== RUN   TestMapNotFound
--- PASS: TestMapNotFound (0.00s)
=== RUN   TestWrapNotFound
--- PASS: TestWrapNotFound (0.00s)
=== RUN   TestRegistrationKeyRepoCRUD
--- PASS: TestRegistrationKeyRepoCRUD (0.05s)
=== RUN   TestRegistrationKeyRepoNotFound
--- PASS: TestRegistrationKeyRepoNotFound (0.01s)
=== RUN   TestSubmissionRepoCreateAndHasCorrect
--- PASS: TestSubmissionRepoCreateAndHasCorrect (0.03s)
=== RUN   TestSubmissionRepoSolvedChallenges
--- PASS: TestSubmissionRepoSolvedChallenges (0.04s)
=== RUN   TestSubmissionRepoSolvedChallengesEmpty
--- PASS: TestSubmissionRepoSolvedChallengesEmpty (0.02s)
=== RUN   TestUserRepoCRUD
--- PASS: TestUserRepoCRUD (0.03s)
=== RUN   TestUserRepoNotFound
--- PASS: TestUserRepoNotFound (0.01s)
=== RUN   TestUserRepoLeaderboardAndTimeline
--- PASS: TestUserRepoLeaderboardAndTimeline (0.05s)
=== RUN   TestUserRepoTimelineNoSince
--- PASS: TestUserRepoTimelineNoSince (0.03s)
=== RUN   TestUserRepoTimelineOrdering
--- PASS: TestUserRepoTimelineOrdering (0.03s)
=== RUN   TestUserRepoListOrdering
--- PASS: TestUserRepoListOrdering (0.04s)
=== RUN   TestUserRepoLeaderboardTieBreak
--- PASS: TestUserRepoLeaderboardTieBreak (0.04s)
=== RUN   TestUserRepoTimelineIncludesUsername
--- PASS: TestUserRepoTimelineIncludesUsername (0.03s)
=== RUN   TestUserRepoCreateDuplicateEmail
[bun]  11:58:26.612   INSERT                  358µs  INSERT INTO "users" ("id", "email", "username", "password_hash", "role", "created_at", "updated_at") VALUES (DEFAULT, 'dup@example.com', 'dup2', 'hash', 'user', '2026-01-29 02:58:26.612486+00:00', '2026-01-29 02:58:26.612486+00:00') RETURNING "id"        pgdriver.Error: ERROR: duplicate key value violates unique constraint "users_email_key" (SQLSTATE=23505) 
--- PASS: TestUserRepoCreateDuplicateEmail (0.01s)
PASS
coverage: 83.0% of statements
2026/01/29 11:58:26 🐳 Stopping container: 71951f01d608
2026/01/29 11:58:26 ✅ Container stopped: 71951f01d608
2026/01/29 11:58:26 🐳 Terminating container: 71951f01d608
2026/01/29 11:58:26 🚫 Container terminated: 71951f01d608
ok      smctf/internal/repo     4.155s  coverage: 83.0% of statements

@codecov
Copy link

codecov bot commented Jan 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@yulmwu yulmwu changed the title Add db, repo package unit test coverage Add db, repo and config package unit test coverage Jan 29, 2026
@yulmwu
Copy link
Member Author

yulmwu commented Jan 29, 2026

image

@yulmwu yulmwu merged commit 5b0391f into main Jan 29, 2026
2 checks passed
@yulmwu yulmwu deleted the tests/improve-coverage branch January 29, 2026 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants