Skip to content

Commit

Permalink
fix: failed tests for accounts api
Browse files Browse the repository at this point in the history
  • Loading branch information
aseerkt committed Apr 12, 2024
1 parent 2df1b73 commit f4de9ce
Show file tree
Hide file tree
Showing 10 changed files with 292 additions and 36 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ on:
jobs:
build-test:
runs-on: ubuntu-latest
env:
DB_URL: postgresql://root:secret@localhost:5432/simple_bank?sslmode=disable
services:
# Label used to access the service container
postgres:
Expand Down Expand Up @@ -44,9 +46,10 @@ jobs:
run: go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/[email protected]

- name: Run migrations
env:
DB_URL: postgresql://root:secret@localhost:5432/simple_bank?sslmode=disable
run: make migrateup

- name: Create env configuration file
run: cp app.sample.env app.env

- name: Test
run: go test -v -cover ./...
4 changes: 2 additions & 2 deletions app.sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ DB_DRIVER=postgres
DB_USER=root
DB_PASSWORD=secret
DB_NAME=simple_bank
DB_PORT=5433
DB_URL="postgresql://root:secret@localhost:5433/simple_bank?sslmode=disable"
DB_PORT=5432
DB_URL="postgresql://root:secret@localhost:5432/simple_bank?sslmode=disable"
DB_CONTAINER_NAME=postgres16

SERVER_ADDRESS=:8080
3 changes: 0 additions & 3 deletions pkg/api/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package api
import (
"database/sql"
"errors"
"fmt"
"net/http"

"github.com/aseerkt/go-simple-bank/pkg/db"
Expand Down Expand Up @@ -35,8 +34,6 @@ func (s *Server) createAccount(c *gin.Context) {

if err != nil {
if pqError, ok := err.(*pq.Error); ok {
fmt.Println(err)
fmt.Println(pqError.Code.Name())
switch pqError.Code.Name() {
case "foreign_key_violation", "unique_violation":
handleForbidden(c, pqError)
Expand Down
Loading

0 comments on commit f4de9ce

Please sign in to comment.