@@ -296,3 +296,64 @@ func TestMakeCommentsIgnoreNoModels(t *testing.T) {
296296 // Assert
297297 assert .Empty (t , err )
298298}
299+
300+ func TestMakeCommentsWithStructCompositionAndCorrectOrder (t * testing.T ) {
301+ type Operation struct {
302+ CreatedAt int64 `json:"-" comment:"Date of creation in seconds since UNIX epoch."`
303+ UpdatedAt int64 `json:"-" comment:"Date of last update in seconds since UNIX epoch."`
304+ Network string `json:"network" pg:",pk" comment:"Identifies belonging network."`
305+ }
306+
307+ type Ballot struct {
308+ //nolint
309+ tableName struct {} `pg:"ballots" comment:"This multiple table name comment"`
310+ Operation
311+ Ballot string `json:"ballot" comment:"This is multiple field comment"`
312+ }
313+
314+ mockCtrl , mockSC , ctx := initMocks (t )
315+ defer mockCtrl .Finish ()
316+
317+ model := Ballot {}
318+
319+ // Assert prepare
320+ tableNameCall := mockSC .
321+ EXPECT ().
322+ MakeTableComment (ctx , "ballots" , "This multiple table name comment" ).
323+ Times (1 ).
324+ Return (nil )
325+
326+ createdAtCall := mockSC .
327+ EXPECT ().
328+ MakeColumnComment (ctx , "ballots" , "created_at" , "Date of creation in seconds since UNIX epoch." ).
329+ After (tableNameCall ).
330+ Times (1 ).
331+ Return (nil )
332+
333+ updatedAtCall := mockSC .
334+ EXPECT ().
335+ MakeColumnComment (ctx , "ballots" , "updated_at" , "Date of last update in seconds since UNIX epoch." ).
336+ After (createdAtCall ).
337+ Times (1 ).
338+ Return (nil )
339+
340+ networkCall := mockSC .
341+ EXPECT ().
342+ MakeColumnComment (ctx , "ballots" , "network" , "Identifies belonging network." ).
343+ After (updatedAtCall ).
344+ Times (1 ).
345+ Return (nil )
346+
347+ mockSC .
348+ EXPECT ().
349+ MakeColumnComment (ctx , "ballots" , "ballot" , "This is multiple field comment" ).
350+ After (networkCall ).
351+ Times (1 ).
352+ Return (nil )
353+
354+ // Act
355+ err := MakeComments (ctx , mockSC , model )
356+
357+ // Assert
358+ assert .Empty (t , err )
359+ }
0 commit comments