Skip to content

Commit 2d7157a

Browse files
committed
Added test TestMakeCommentsWithMultipleModelsByPointers.
1 parent 8f1fc94 commit 2d7157a

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

database/pgComment_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,37 @@ func TestMakeCommentsWithMultipleModels(t *testing.T) {
178178
// Assert
179179
assert.Empty(t, err)
180180
}
181+
182+
func TestMakeCommentsWithMultipleModelsByPointers(t *testing.T) {
183+
type Ballot struct {
184+
//nolint
185+
tableName struct{} `pg:"ballots" pg-comment:"This multiple table name comment"`
186+
Ballot string `json:"ballot" pg-comment:"This is multiple field comment"`
187+
}
188+
189+
mockCtrl, mockSC, ctx := initMocks(t)
190+
defer mockCtrl.Finish()
191+
192+
models := []interface{}{&Ballot{}, &Ballot{}, &Ballot{}}
193+
194+
// Assert prepare
195+
mockSC.
196+
EXPECT().
197+
MakeTableComment(ctx, "ballots", "This multiple table name comment").
198+
Times(3).
199+
Return(nil)
200+
201+
// Be aware: there is on issue with default order in checking
202+
// methods call: https://github.com/golang/mock/issues/653
203+
mockSC.
204+
EXPECT().
205+
MakeColumnComment(ctx, "ballots", "ballot", "This is multiple field comment").
206+
Times(3).
207+
Return(nil)
208+
209+
// Act
210+
err := MakeComments(ctx, mockSC, models...)
211+
212+
// Assert
213+
assert.Empty(t, err)
214+
}

0 commit comments

Comments
 (0)