Skip to content

Commit e221dbd

Browse files
committed
Format fix with go-fmt
1 parent f91b313 commit e221dbd

2 files changed

Lines changed: 46 additions & 47 deletions

File tree

go/database/sql/connection_test.go

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,58 @@
11
package sql
22

33
import (
4-
"testing"
54
"context"
65
"github.com/google/sqlcommenter/go/core"
6+
"testing"
77
)
88

99
func TestWithComment_NoContext(t *testing.T) {
1010
testBasicConn := &mockConn{}
1111
testCases := []struct {
12-
desc string
12+
desc string
1313
commenterOptions core.CommenterOptions
14-
query string
15-
wantQuery string
16-
} {
14+
query string
15+
wantQuery string
16+
}{
1717
{
18-
desc: "empty commenter options",
18+
desc: "empty commenter options",
1919
commenterOptions: core.CommenterOptions{},
20-
query: "SELECT 1;",
21-
wantQuery: "SELECT 1;",
20+
query: "SELECT 1;",
21+
wantQuery: "SELECT 1;",
2222
},
2323
{
2424
desc: "only enable DBDriver",
2525
commenterOptions: core.CommenterOptions{
2626
Config: core.CommenterConfig{EnableDBDriver: true},
2727
},
28-
query: "SELECT 1;",
28+
query: "SELECT 1;",
2929
wantQuery: "SELECT 1/*db_driver=database%2Fsql%3A*/;",
3030
},
3131
{
3232
desc: "enable DBDriver and pass static tag driver name",
3333
commenterOptions: core.CommenterOptions{
3434
Config: core.CommenterConfig{EnableDBDriver: true},
35-
Tags: core.StaticTags{DriverName: "postgres"},
35+
Tags: core.StaticTags{DriverName: "postgres"},
3636
},
37-
query: "SELECT 1;",
37+
query: "SELECT 1;",
3838
wantQuery: "SELECT 1/*db_driver=database%2Fsql%3Apostgres*/;",
3939
},
4040
{
4141
desc: "enable DBDriver and pass all static tags",
4242
commenterOptions: core.CommenterOptions{
4343
Config: core.CommenterConfig{EnableDBDriver: true},
44-
Tags: core.StaticTags{DriverName: "postgres", Application: "app-1"},
44+
Tags: core.StaticTags{DriverName: "postgres", Application: "app-1"},
4545
},
46-
query: "SELECT 1;",
46+
query: "SELECT 1;",
4747
wantQuery: "SELECT 1/*db_driver=database%2Fsql%3Apostgres*/;",
4848
},
4949
{
5050
desc: "enable other tags and pass all static tags",
5151
commenterOptions: core.CommenterOptions{
5252
Config: core.CommenterConfig{EnableDBDriver: true, EnableApplication: true, EnableFramework: true},
53-
Tags: core.StaticTags{DriverName: "postgres", Application: "app-1"},
53+
Tags: core.StaticTags{DriverName: "postgres", Application: "app-1"},
5454
},
55-
query: "SELECT 1;",
55+
query: "SELECT 1;",
5656
wantQuery: "SELECT 1/*application=app-1,db_driver=database%2Fsql%3Apostgres*/;",
5757
},
5858
}
@@ -68,70 +68,70 @@ func TestWithComment_NoContext(t *testing.T) {
6868
func TestWithComment_WithContext(t *testing.T) {
6969
testBasicConn := &mockConn{}
7070
testCases := []struct {
71-
desc string
71+
desc string
7272
commenterOptions core.CommenterOptions
73-
ctx context.Context
74-
query string
75-
wantQuery string
76-
} {
73+
ctx context.Context
74+
query string
75+
wantQuery string
76+
}{
7777
{
78-
desc: "empty commenter options",
78+
desc: "empty commenter options",
7979
commenterOptions: core.CommenterOptions{},
8080
ctx: getContextWithKeyValue(
81-
map[string]string {
82-
"route": "listData",
81+
map[string]string{
82+
"route": "listData",
8383
"framework": "custom-golang",
8484
},
8585
),
86-
query: "SELECT 1;",
86+
query: "SELECT 1;",
8787
wantQuery: "SELECT 1;",
8888
},
8989
{
9090
desc: "only all options but context has few tags",
9191
commenterOptions: core.CommenterOptions{
9292
Config: core.CommenterConfig{
93-
EnableDBDriver: true,
94-
EnableRoute: true,
95-
EnableFramework: true,
96-
EnableController: true,
97-
EnableAction: true,
93+
EnableDBDriver: true,
94+
EnableRoute: true,
95+
EnableFramework: true,
96+
EnableController: true,
97+
EnableAction: true,
9898
EnableTraceparent: true,
9999
EnableApplication: true,
100100
},
101101
Tags: core.StaticTags{DriverName: "postgres", Application: "app-1"},
102102
},
103103
ctx: getContextWithKeyValue(
104-
map[string]string {
105-
"route": "listData",
104+
map[string]string{
105+
"route": "listData",
106106
"framework": "custom-golang",
107107
},
108108
),
109-
query: "SELECT 1;",
109+
query: "SELECT 1;",
110110
wantQuery: "SELECT 1/*application=app-1,db_driver=database%2Fsql%3Apostgres,framework=custom-golang,route=listData*/;",
111111
},
112112
{
113113
desc: "only all options but context contains all tags",
114114
commenterOptions: core.CommenterOptions{
115115
Config: core.CommenterConfig{
116-
EnableDBDriver: true,
117-
EnableRoute: true,
118-
EnableFramework: true,
119-
EnableController: true,
120-
EnableAction: true,
116+
EnableDBDriver: true,
117+
EnableRoute: true,
118+
EnableFramework: true,
119+
EnableController: true,
120+
EnableAction: true,
121121
EnableTraceparent: true,
122122
EnableApplication: true,
123123
},
124124
Tags: core.StaticTags{DriverName: "postgres", Application: "app-1"},
125125
},
126126
ctx: getContextWithKeyValue(
127-
map[string]string {
128-
"route": "listData",
129-
"framework": "custom-golang",
127+
map[string]string{
128+
"route": "listData",
129+
"framework": "custom-golang",
130130
"controller": "custom-controller",
131-
"action": "any action",
131+
"action": "any action",
132132
},
133133
),
134-
query: "SELECT 1;",
134+
query: "SELECT 1;",
135135
wantQuery: "SELECT 1/*action=any+action,application=app-1,db_driver=database%2Fsql%3Apostgres,framework=custom-golang,route=listData*/;",
136136
},
137137
}

go/database/sql/gosql_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ import (
2020

2121
type mockConn struct {
2222
prepareStmt driver.Stmt
23-
prepareErr error
23+
prepareErr error
2424

2525
closeErr error
2626

27-
beginTx driver.Tx
27+
beginTx driver.Tx
2828
beginErr error
2929
}
3030

@@ -43,11 +43,11 @@ func (c *mockConn) Begin() (driver.Tx, error) {
4343
if c.beginErr != nil {
4444
return nil, c.beginErr
4545
}
46-
return c.beginTx, nil
46+
return c.beginTx, nil
4747
}
4848

4949
type mockDriver struct {
50-
conn driver.Conn
50+
conn driver.Conn
5151
openError error
5252
}
5353

@@ -57,4 +57,3 @@ func (d *mockDriver) Open(name string) (driver.Conn, error) {
5757
}
5858
return d.conn, nil
5959
}
60-

0 commit comments

Comments
 (0)