feat: fix issues

This commit is contained in:
Rogee
2025-05-26 12:25:55 +08:00
parent 51ed5685dc
commit d634e0175b
10 changed files with 43 additions and 17 deletions

View File

@@ -64,3 +64,18 @@ func (s *PostsTestSuite) Test_Create() {
So(post.UpdatedAt, ShouldNotBeZeroValue)
})
}
func (s *PostsTestSuite) Test_IncrView() {
Convey("Test_IncrView", s.T(), func() {
// database.Truncate(context.Background(), db, tblPosts.TableName())
post, err := PostsModel().GetByID(context.Background(), 1)
So(err, ShouldBeNil)
oldViews := post.Views
So(post, ShouldNotBeNil)
err = post.IncrViewCount(context.Background())
So(err, ShouldBeNil)
So(post.Views, ShouldBeGreaterThan, oldViews)
})
}