From 8af404298d9e9ec85c4f544e63914b1ab4410a2c Mon Sep 17 00:00:00 2001 From: "Kirk.Wang" Date: Fri, 19 Apr 2019 21:01:30 +0800 Subject: [PATCH] add user_test.go --- database/database_test.go | 26 -------------------------- database/user_test.go | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 26 deletions(-) create mode 100644 database/user_test.go diff --git a/database/database_test.go b/database/database_test.go index 270dc86..78d2608 100644 --- a/database/database_test.go +++ b/database/database_test.go @@ -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: "Sincere@april.biz", - 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) diff --git a/database/user_test.go b/database/user_test.go new file mode 100644 index 0000000..868c689 --- /dev/null +++ b/database/user_test.go @@ -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: "Sincere@april.biz", + 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) +}