Skip to content

Commit cb84dc5

Browse files
Add test
1 parent 4212fd7 commit cb84dc5

File tree

5 files changed

+53
-0
lines changed

5 files changed

+53
-0
lines changed

.github/workflows/test.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Go package
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
12+
- name: Set up Go
13+
uses: actions/setup-go@v2
14+
with:
15+
go-version: 1.23
16+
17+
- name: Build
18+
run: go build -v cmd/
19+
20+
- name: Test
21+
run: go test -v ./...

Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
run:
33
go build -o ./bin/todo ./cmd/todo
44
./bin/todo
5+
6+
test:
7+
go test ./...

go.mod

+4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ module ai-coding-comparison
33
go 1.23.3
44

55
require (
6+
github.com/davecgh/go-spew v1.1.1 // indirect
67
github.com/jinzhu/inflection v1.0.0 // indirect
78
github.com/jinzhu/now v1.1.5 // indirect
89
github.com/mattn/go-sqlite3 v1.14.24 // indirect
10+
github.com/pmezard/go-difflib v1.0.0 // indirect
11+
github.com/stretchr/testify v1.9.0 // indirect
912
golang.org/x/text v0.20.0 // indirect
13+
gopkg.in/yaml.v3 v3.0.1 // indirect
1014
gorm.io/driver/sqlite v1.5.6 // indirect
1115
gorm.io/gorm v1.25.12 // indirect
1216
)

go.sum

+9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
1+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
2+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
13
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
24
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
35
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
46
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
57
github.com/mattn/go-sqlite3 v1.14.24 h1:tpSp2G2KyMnnQu99ngJ47EIkWVmliIizyZBfPrBWDRM=
68
github.com/mattn/go-sqlite3 v1.14.24/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
9+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
10+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
11+
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
12+
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
713
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
814
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
15+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
16+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
17+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
918
gorm.io/driver/sqlite v1.5.6 h1:fO/X46qn5NUEEOZtnjJRWRzZMe8nqJiQ9E+0hi+hKQE=
1019
gorm.io/driver/sqlite v1.5.6/go.mod h1:U+J8craQU6Fzkcvu8oLeAQmi50TkwPEhHDEjQZXDah4=
1120
gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8=

internal/todo/domain/todo_test.go

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package domain
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
)
8+
9+
func TestTodoCreation(t *testing.T) {
10+
todo := Todo{
11+
Title: "Test Todo",
12+
}
13+
14+
// Using testify's assert package for better readability
15+
assert.Equal(t, "Test Todo", todo.Title, "Title should be 'Test Todo'")
16+
}

0 commit comments

Comments
 (0)