Skip to content

Commit

Permalink
udpate unit tests(TestGetPostByID)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirk-Wang committed Apr 29, 2019
1 parent 5be07f6 commit 34a9ef6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 0 additions & 6 deletions database/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ func (s *DatabaseSuite) TestPost() {
assert.Nil(s.T(), err)
}

func (s *DatabaseSuite) TestGetPostByID() {
id, _ := primitive.ObjectIDFromHex("5c92e6199929adef73bceea1")
post := s.db.GetPostByID(id)
assert.Equal(s.T(), "tile1", post.Title)
}

func (s *DatabaseSuite) TestUpdatePost() {
id, _ := primitive.ObjectIDFromHex("5c92e6199929adef73bceea1")
userID, _ := primitive.ObjectIDFromHex("5c8f9a83da2c3fed4eee9dc1")
Expand Down
7 changes: 7 additions & 0 deletions database/post_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package database
import (
"github.com/lotteryjs/ten-minutes-app/model"
"github.com/stretchr/testify/assert"
"go.mongodb.org/mongo-driver/bson/primitive"
)

func (s *DatabaseSuite) TestCreatePost() {
Expand All @@ -25,3 +26,9 @@ func (s *DatabaseSuite) TestCreatePost() {
func (s *DatabaseSuite) TestCountPost() {
assert.Equal(s.T(), "1", s.db.CountPost(nil))
}

func (s *DatabaseSuite) TestGetPostByID() {
id, _ := primitive.ObjectIDFromHex("5cc5ca2f6a670dd59ea3a590")
post := s.db.GetPostByID(id)
assert.Equal(s.T(), "title1", post.Title)
}

0 comments on commit 34a9ef6

Please sign in to comment.