Skip to content

Commit

Permalink
add user_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirk-Wang committed Apr 19, 2019
1 parent 8e8a7a2 commit 8af4042
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 26 deletions.
26 changes: 0 additions & 26 deletions database/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,32 +29,6 @@ func (s *DatabaseSuite) AfterTest(suiteName, testName string) {
}

func (s *DatabaseSuite) TestUser() {
s.db.DB.Collection("users").Drop(nil)

kirk := (&model.User{
Name: "Leanne Graham",
UserName: "Bret",
Email: "[email protected]",
Address: model.UserAddress{
Street: "Kulas Light",
Suite: "Apt. 556",
City: "Gwenborough",
Zipcode: "92998-3874",
Geo: model.UserAddressGeo{
Lat: "-37.3159",
Lng: "81.1496",
},
},
Phone: "1-770-736-8031 x56442",
Website: "hildegard.org",
Company: model.UserCompany{
Name: "Romaguera-Crona",
CatchPhrase: "Multi-layered client-server neural-net",
BS: "harness real-time e-markets",
},
}).New()
err := s.db.CreateUser(kirk)
assert.Nil(s.T(), err)

start := int64(0)
limit := int64(10)
Expand Down
35 changes: 35 additions & 0 deletions database/user_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package database

import (
"github.com/lotteryjs/ten-minutes-app/model"
"github.com/stretchr/testify/assert"
)

func (s *DatabaseSuite) TestCreateUser() {
s.db.DB.Collection("users").Drop(nil)

kirk := (&model.User{
Name: "Graham",
UserName: "Bret",
Email: "[email protected]",
Address: model.UserAddress{
Street: "Kulas Light",
Suite: "Apt. 556",
City: "Gwenborough",
Zipcode: "92998-3874",
Geo: model.UserAddressGeo{
Lat: "-37.3159",
Lng: "81.1496",
},
},
Phone: "1-770-736-8031 x56442",
Website: "hildegard.org",
Company: model.UserCompany{
Name: "Romaguera-Crona",
CatchPhrase: "Multi-layered client-server neural-net",
BS: "harness real-time e-markets",
},
}).New()
err := s.db.CreateUser(kirk)
assert.Nil(s.T(), err)
}

0 comments on commit 8af4042

Please sign in to comment.