Skip to content

Commit

Permalink
Fix bug with client initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
josephspurrier committed Mar 7, 2017
1 parent 427ec93 commit 7b02a47
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions database/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type Service interface {
func NewClient(path string) *Client {
c := &Client{
Path: path,
data: new(Schema),
}

return c
Expand Down
8 changes: 8 additions & 0 deletions database/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"

"github.com/josephspurrier/gocleanarchitecture/database"
"github.com/josephspurrier/gocleanarchitecture/domain/user"
)

// TestClient ensures the client works properly.
Expand All @@ -17,6 +18,13 @@ func TestClient(t *testing.T) {
AssertEqual(t, c.Read(), nil)
AssertEqual(t, c.Write(), nil)

// Test adding a record and reading it.
u := new(user.Item)
u.Email = "jdoe@example.com"
u.Password = "Pa$$w0rd"
c.AddRecord(*u)
AssertEqual(t, len(c.Records()), 1)

// Cleanup
os.Remove("db.json")
}

0 comments on commit 7b02a47

Please sign in to comment.