feat: update
This commit is contained in:
@@ -52,7 +52,7 @@ func (s *MediasTestSuite) Test_countByCondition() {
|
||||
Convey("no cond", func() {
|
||||
database.Truncate(context.Background(), db, table.Medias.TableName())
|
||||
|
||||
cnt, err := MediasModel.countByCondition(context.Background(), nil)
|
||||
cnt, err := MediasModel().countByCondition(context.Background(), nil)
|
||||
Convey("should not return an error", func() {
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
@@ -110,7 +110,7 @@ func (s *MediasTestSuite) Test_BatchCreate() {
|
||||
|
||||
count := 10
|
||||
for i := 0; i < count; i++ {
|
||||
err := MediasModel.BatchCreate(context.Background(), models)
|
||||
err := MediasModel().BatchCreate(context.Background(), models)
|
||||
Convey("Create should not return an error: "+fmt.Sprintf("%d", i), func() {
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
@@ -132,12 +132,12 @@ func (s *MediasTestSuite) Test_Create() {
|
||||
Path: "path/to/media.pdf",
|
||||
}
|
||||
|
||||
err := MediasModel.Create(context.Background(), model)
|
||||
err := MediasModel().Create(context.Background(), model)
|
||||
Convey("Create should not return an error", func() {
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
|
||||
cnt, err := MediasModel.countByCondition(context.Background(), nil)
|
||||
cnt, err := MediasModel().countByCondition(context.Background(), nil)
|
||||
Convey("Count should not return an error", func() {
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
@@ -165,31 +165,31 @@ func (s *MediasTestSuite) Test_Page() {
|
||||
Path: "path/to/media.pdf",
|
||||
}
|
||||
|
||||
err := MediasModel.Create(context.Background(), model)
|
||||
err := MediasModel().Create(context.Background(), model)
|
||||
So(err, ShouldBeNil)
|
||||
}
|
||||
|
||||
cnt, err := MediasModel.countByCondition(context.Background(), nil)
|
||||
cnt, err := MediasModel().countByCondition(context.Background(), nil)
|
||||
So(err, ShouldBeNil)
|
||||
So(cnt, ShouldEqual, 20)
|
||||
})
|
||||
|
||||
Convey("Page", func() {
|
||||
Convey("page 1", func() {
|
||||
pager, err := MediasModel.List(context.Background(), &requests.Pagination{Page: 1, Limit: 10}, nil)
|
||||
pager, err := MediasModel().List(context.Background(), &requests.Pagination{Page: 1, Limit: 10}, nil)
|
||||
So(err, ShouldBeNil)
|
||||
So(pager.Total, ShouldEqual, 20)
|
||||
So(pager.Items, ShouldHaveLength, 10)
|
||||
})
|
||||
Convey("page 2", func() {
|
||||
pager, err := MediasModel.List(context.Background(), &requests.Pagination{Page: 2, Limit: 10}, nil)
|
||||
pager, err := MediasModel().List(context.Background(), &requests.Pagination{Page: 2, Limit: 10}, nil)
|
||||
So(err, ShouldBeNil)
|
||||
So(pager.Total, ShouldEqual, 20)
|
||||
So(pager.Items, ShouldHaveLength, 10)
|
||||
})
|
||||
|
||||
Convey("page 3", func() {
|
||||
pager, err := MediasModel.List(context.Background(), &requests.Pagination{Page: 3, Limit: 10}, nil)
|
||||
pager, err := MediasModel().List(context.Background(), &requests.Pagination{Page: 3, Limit: 10}, nil)
|
||||
So(err, ShouldBeNil)
|
||||
So(pager.Total, ShouldEqual, 20)
|
||||
So(pager.Items, ShouldBeEmpty)
|
||||
@@ -208,7 +208,7 @@ func (s *MediasTestSuite) Test_CreateGetID() {
|
||||
Path: "path/to/media.pdf",
|
||||
}
|
||||
|
||||
err := MediasModel.Create(context.Background(), model)
|
||||
err := MediasModel().Create(context.Background(), model)
|
||||
So(err, ShouldBeNil)
|
||||
So(model.ID, ShouldNotBeEmpty)
|
||||
|
||||
@@ -219,7 +219,7 @@ func (s *MediasTestSuite) Test_CreateGetID() {
|
||||
func (s *MediasTestSuite) Test_GetRelations() {
|
||||
Convey("GetByHash", s.T(), func() {
|
||||
hash := "ce4cd071128cef282cf315dda75bdab4"
|
||||
media, err := MediasModel.GetRelations(context.Background(), hash)
|
||||
media, err := MediasModel().GetRelations(context.Background(), hash)
|
||||
So(err, ShouldBeNil)
|
||||
So(media, ShouldNotBeNil)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user