Skip to content

Commit

Permalink
Fix SQLCommenter database/sql test (#221)
Browse files Browse the repository at this point in the history
* Updated database/sql to use core-0.1.2

* Fix SQLCommenter database/sql test

* Ran go mod tidy
  • Loading branch information
sjs994 committed Dec 22, 2022
1 parent 619477b commit 3018fe7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
12 changes: 6 additions & 6 deletions go/database/sql/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestWithComment_NoContext(t *testing.T) {
Config: core.CommenterConfig{EnableDBDriver: true},
},
query: "SELECT 1;",
wantQuery: "SELECT 1/*db_driver=database%2Fsql%3A*/;",
wantQuery: "SELECT 1/*db_driver='database%2Fsql%3A'*/;",
},
{
desc: "enable DBDriver and pass static tag driver name",
Expand All @@ -50,7 +50,7 @@ func TestWithComment_NoContext(t *testing.T) {
Tags: core.StaticTags{DriverName: "postgres"},
},
query: "SELECT 1;",
wantQuery: "SELECT 1/*db_driver=database%2Fsql%3Apostgres*/;",
wantQuery: "SELECT 1/*db_driver='database%2Fsql%3Apostgres'*/;",
},
{
desc: "enable DBDriver and pass all static tags",
Expand All @@ -59,7 +59,7 @@ func TestWithComment_NoContext(t *testing.T) {
Tags: core.StaticTags{DriverName: "postgres", Application: "app-1"},
},
query: "SELECT 1;",
wantQuery: "SELECT 1/*db_driver=database%2Fsql%3Apostgres*/;",
wantQuery: "SELECT 1/*db_driver='database%2Fsql%3Apostgres'*/;",
},
{
desc: "enable other tags and pass all static tags",
Expand All @@ -68,7 +68,7 @@ func TestWithComment_NoContext(t *testing.T) {
Tags: core.StaticTags{DriverName: "postgres", Application: "app-1"},
},
query: "SELECT 1;",
wantQuery: "SELECT 1/*application=app-1,db_driver=database%2Fsql%3Apostgres*/;",
wantQuery: "SELECT 1/*application='app-1',db_driver='database%2Fsql%3Apostgres'*/;",
},
}
for _, tc := range testCases {
Expand Down Expand Up @@ -122,7 +122,7 @@ func TestWithComment_WithContext(t *testing.T) {
},
),
query: "SELECT 1;",
wantQuery: "SELECT 1/*application=app-1,db_driver=database%2Fsql%3Apostgres,framework=custom-golang,route=listData*/;",
wantQuery: "SELECT 1/*application='app-1',db_driver='database%2Fsql%3Apostgres',framework='custom-golang',route='listData'*/;",
},
{
desc: "only all options but context contains all tags",
Expand All @@ -147,7 +147,7 @@ func TestWithComment_WithContext(t *testing.T) {
},
),
query: "SELECT 1;",
wantQuery: "SELECT 1/*action=any+action,application=app-1,db_driver=database%2Fsql%3Apostgres,framework=custom-golang,route=listData*/;",
wantQuery: "SELECT 1/*action='any+action',application='app-1',db_driver='database%2Fsql%3Apostgres',framework='custom-golang',route='listData'*/;",
},
}
for _, tc := range testCases {
Expand Down
2 changes: 1 addition & 1 deletion go/database/sql/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/google/sqlcommenter/go/database/sql

go 1.19

require github.com/google/sqlcommenter/go/core v0.1.0
require github.com/google/sqlcommenter/go/core v0.1.2

require go.opentelemetry.io/otel v1.11.1 // indirect

Expand Down
6 changes: 2 additions & 4 deletions go/database/sql/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/sqlcommenter/go/core v0.0.5-beta h1:axqYR1zQCCdRBLnwr/j+ckllBSBJ7uaVdsnANuGzCUI=
github.com/google/sqlcommenter/go/core v0.0.5-beta/go.mod h1:GORu2htXRC4xtejBzOa4ct1L20pohP81DFNYKdCJI70=
github.com/google/sqlcommenter/go/core v0.1.0 h1:g5jL8HUk2Ko9mMPoCI4jP47dyJhpNyu6E8WmiEhh8OU=
github.com/google/sqlcommenter/go/core v0.1.0/go.mod h1:GORu2htXRC4xtejBzOa4ct1L20pohP81DFNYKdCJI70=
github.com/google/sqlcommenter/go/core v0.1.2 h1:UM3jS7JROrPTsJxbLq68PRB34Iq8H3AZQDQUSV7sQWU=
github.com/google/sqlcommenter/go/core v0.1.2/go.mod h1:GORu2htXRC4xtejBzOa4ct1L20pohP81DFNYKdCJI70=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
go.opentelemetry.io/otel v1.11.1 h1:4WLLAmcfkmDk2ukNXJyq3/kiz/3UzCaYq6PskJsaou4=
Expand Down

0 comments on commit 3018fe7

Please sign in to comment.