File tree Expand file tree Collapse file tree 5 files changed +50
-1
lines changed
Expand file tree Collapse file tree 5 files changed +50
-1
lines changed Original file line number Diff line number Diff line change 1+ {
2+ Name: "with relations",
3+ Columns: []schema.Column{
4+
5+ },
6+
7+ Relations: []*schema.Table{
8+ relation1,
9+ relation2,
10+
11+ },
12+
13+ }
Original file line number Diff line number Diff line change @@ -6,9 +6,11 @@ import (
66 "testing"
77 "time"
88
9+ "github.com/bradleyjkemp/cupaloy"
910 "github.com/cloudquery/plugin-sdk/schema"
1011 "github.com/google/go-cmp/cmp"
1112 "github.com/google/go-cmp/cmp/cmpopts"
13+ "github.com/stretchr/testify/require"
1214)
1315
1416type testStruct struct {
@@ -98,3 +100,33 @@ func TestTableFromGoStruct(t *testing.T) {
98100// func TestReadComments(t *testing.T) {
99101// readComments("github.com/google/go-cmp/cmp")
100102// }
103+
104+ func TestGenerateTemplate (t * testing.T ) {
105+ type args struct {
106+ table * TableDefinition
107+ }
108+
109+ tests := []struct {
110+ name string
111+ args args
112+ }{
113+ {
114+ name : "should add comma between relations" ,
115+ args : args {
116+ table : & TableDefinition {
117+ Name : "with relations" ,
118+ Relations : []string {"relation1" , "relation2" },
119+ },
120+ },
121+ },
122+ }
123+
124+ for _ , tt := range tests {
125+ t .Run (tt .name , func (t * testing.T ) {
126+ buf := bytes .NewBufferString ("" )
127+ err := tt .args .table .GenerateTemplate (buf )
128+ require .NoError (t , err )
129+ cupaloy .SnapshotT (t , buf .Bytes ())
130+ })
131+ }
132+ }
Original file line number Diff line number Diff line change 2020 },
2121{ {with .Relations} }
2222 Relations: []*schema.Table{
23- {{range .} }{ {.} }{ {end} },
23+ {{range .} }{ {.} },
24+ { {end} }
2425 },
2526{ {end} }
2627}
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ require (
2727)
2828
2929require (
30+ github.com/bradleyjkemp/cupaloy v2.3.0+incompatible // indirect
3031 github.com/davecgh/go-spew v1.1.1 // indirect
3132 github.com/gogo/protobuf v1.3.2 // indirect
3233 github.com/golang/protobuf v1.5.2 // indirect
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
22cloud.google.com/go v0.34.0 /go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw =
33github.com/BurntSushi/toml v0.3.1 /go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU =
44github.com/antihax/optional v1.0.0 /go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY =
5+ github.com/bradleyjkemp/cupaloy v2.3.0+incompatible h1:UafIjBvWQmS9i/xRg+CamMrnLTKNzo+bdmT/oH34c2Y =
6+ github.com/bradleyjkemp/cupaloy v2.3.0+incompatible /go.mod h1:Au1Xw1sgaJ5iSFktEhYsS0dbQiS1B0/XMXl+42y9Ilk =
57github.com/census-instrumentation/opencensus-proto v0.2.1 /go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU =
68github.com/cespare/xxhash/v2 v2.1.1 /go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs =
79github.com/client9/misspell v0.3.4 /go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw =
You can’t perform that action at this time.
0 commit comments