Skip to content

Commit ec84ddf

Browse files
authored
feat: Add support for IgnoreInTests for columns during codegen (#153)
1 parent 5454c73 commit ec84ddf

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
Name: "with relations",
3+
Columns: []schema.Column{
4+
{
5+
Name: "ignore_in_tests",
6+
Type: schema.TypeString,
7+
IgnoreInTests: true,
8+
},
9+
10+
},
11+
12+
}

codegen/golang_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ type testStruct struct {
3434
JSONTAG *string `json:"json_tag"`
3535
SKIPJSONTAG *string `json:"-"`
3636
NOJSONTAG *string
37+
3738
*embeddedStruct
3839
}
3940

@@ -201,6 +202,17 @@ func TestGenerateTemplate(t *testing.T) {
201202
},
202203
},
203204
},
205+
{
206+
name: "should add ignore_in_tests to columns",
207+
args: args{
208+
table: &TableDefinition{
209+
Name: "with relations",
210+
Columns: []ColumnDefinition{
211+
{Name: "ignore_in_tests", Type: schema.TypeString, IgnoreInTests: true},
212+
},
213+
},
214+
},
215+
},
204216
}
205217

206218
for _, tt := range tests {

codegen/templates/column.go.tpl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,8 @@
1313
PrimaryKey: true,
1414
{{- end }}
1515
},
16-
{{- end}}
16+
{{- end}}
17+
{{- if .IgnoreInTests}}
18+
IgnoreInTests: true,
19+
{{- end}}
1720
},

0 commit comments

Comments
 (0)