Skip to content

Commit

Permalink
(+) new server error
Browse files Browse the repository at this point in the history
  • Loading branch information
maulana48 committed Jul 15, 2023
1 parent 347b84e commit 547c256
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
8 changes: 7 additions & 1 deletion api/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/http/httptest"
"testing"
Expand Down Expand Up @@ -87,10 +88,15 @@ func TestGetAccountAPI(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()

config, err := util.LoadConfig(".")
if err != nil {
log.Fatal("cannot load config:", err)
}

store := mockdb.NewMockStore(ctrl)
tc.buildStubs(store)

server, err := NewServer(store)
server, err := NewServer(config, store)
require.NoError(t, err)
recorder := httptest.NewRecorder()

Expand Down
2 changes: 2 additions & 0 deletions db/sqlc/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"context"
"database/sql"
"fmt"

_ "github.com/golang/mock/mockgen/model"
)

type Store interface {
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func main() {
}

store := db.NewStore(conn)
server, err := api.NewServer(store)
server, err := api.NewServer(config, store)
if err != nil {
log.Fatal("cannot start server:", err)
}
Expand Down
7 changes: 6 additions & 1 deletion test/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"database/sql"
"encoding/json"
"fmt"
"log"
"net/http"
"net/http/httptest"
"reflect"
Expand Down Expand Up @@ -219,11 +220,15 @@ func TestCreateUserAPI(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
config, err := util.LoadConfig(".")
if err != nil {
log.Fatal("cannot load config:", err)
}

store := mockdb.NewMockStore(ctrl)
tc.buildStubs(store)

server, err := api.NewServer(store)
server, err := api.NewServer(config, store)
recorder := httptest.NewRecorder()

// Marshal body data to JSON
Expand Down

0 comments on commit 547c256

Please sign in to comment.