linting and formatting
This commit is contained in:
parent
8fe6d00e71
commit
6c2e70d09c
@ -1,5 +1,5 @@
|
|||||||
when:
|
when:
|
||||||
- event: push
|
- event: [push, pull_request]
|
||||||
branch: main
|
branch: main
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
9
.woodpecker/lint.yaml
Normal file
9
.woodpecker/lint.yaml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
when:
|
||||||
|
- event: [push, pull_request]
|
||||||
|
branch: main
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: build
|
||||||
|
image: golangci-lint
|
||||||
|
commands:
|
||||||
|
- golangci-lint run
|
@ -1,5 +1,5 @@
|
|||||||
when:
|
when:
|
||||||
- event: push
|
- event: [push, pull_request]
|
||||||
branch: main
|
branch: main
|
||||||
|
|
||||||
# go again
|
# go again
|
||||||
@ -13,3 +13,6 @@ steps:
|
|||||||
commands:
|
commands:
|
||||||
- go get ./...
|
- go get ./...
|
||||||
- go test ./... -v
|
- go test ./... -v
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- build
|
||||||
|
12
cmd/main.go
12
cmd/main.go
@ -12,8 +12,8 @@ import (
|
|||||||
todohandler "gitea.michaelthomson.dev/mthomson/habits/internal/todo/handler"
|
todohandler "gitea.michaelthomson.dev/mthomson/habits/internal/todo/handler"
|
||||||
todorepository "gitea.michaelthomson.dev/mthomson/habits/internal/todo/repository/postgres"
|
todorepository "gitea.michaelthomson.dev/mthomson/habits/internal/todo/repository/postgres"
|
||||||
todoservice "gitea.michaelthomson.dev/mthomson/habits/internal/todo/service"
|
todoservice "gitea.michaelthomson.dev/mthomson/habits/internal/todo/service"
|
||||||
_ "github.com/mattn/go-sqlite3"
|
|
||||||
_ "github.com/jackc/pgx/v5/stdlib"
|
_ "github.com/jackc/pgx/v5/stdlib"
|
||||||
|
_ "github.com/mattn/go-sqlite3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -27,7 +27,7 @@ func main() {
|
|||||||
postgresUrl := "postgres://todo:password@localhost:5432/todo"
|
postgresUrl := "postgres://todo:password@localhost:5432/todo"
|
||||||
db, err := sql.Open("pgx", postgresUrl)
|
db, err := sql.Open("pgx", postgresUrl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("Failed to open db pool")
|
log.Fatalf("Failed to open db pool: %v", err)
|
||||||
}
|
}
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
||||||
@ -51,9 +51,13 @@ func main() {
|
|||||||
|
|
||||||
// create server
|
// create server
|
||||||
server := &http.Server{
|
server := &http.Server{
|
||||||
Addr: ":8080",
|
Addr: ":8080",
|
||||||
Handler: mux,
|
Handler: mux,
|
||||||
}
|
}
|
||||||
|
|
||||||
server.ListenAndServe()
|
err = server.ListenAndServe()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("Failed to start server: %v", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type TestDatabase struct {
|
type TestDatabase struct {
|
||||||
Db *sql.DB
|
Db *sql.DB
|
||||||
container testcontainers.Container
|
container testcontainers.Container
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func NewTestDatabase() *TestDatabase {
|
func NewTestDatabase() *TestDatabase {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
// create container
|
// create container
|
||||||
@ -33,7 +32,7 @@ func NewTestDatabase() *TestDatabase {
|
|||||||
wait.ForLog("database system is ready to accept connections").
|
wait.ForLog("database system is ready to accept connections").
|
||||||
WithOccurrence(2).
|
WithOccurrence(2).
|
||||||
WithStartupTimeout(5*time.Second)),
|
WithStartupTimeout(5*time.Second)),
|
||||||
)
|
)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Failed to create postgres container, %v\n", err)
|
log.Fatalf("Failed to create postgres container, %v\n", err)
|
||||||
@ -53,7 +52,7 @@ func NewTestDatabase() *TestDatabase {
|
|||||||
migrate.Migrate(db)
|
migrate.Migrate(db)
|
||||||
|
|
||||||
return &TestDatabase{
|
return &TestDatabase{
|
||||||
Db: db,
|
Db: db,
|
||||||
container: postgresContainer,
|
container: postgresContainer,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user