Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SQLCommenter database/sql test #221

Merged
merged 3 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: 6 additions & 0 deletions go/database/sql/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ github.com/google/sqlcommenter/go/core v0.0.5-beta h1:axqYR1zQCCdRBLnwr/j+ckllBS
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.1 h1:DXaWbnQHJ00RqqGiyySPnaNHLqWuemtdP1DIheVXa/A=
github.com/google/sqlcommenter/go/core v0.1.1/go.mod h1:GORu2htXRC4xtejBzOa4ct1L20pohP81DFNYKdCJI70=
github.com/google/sqlcommenter/go/core v0.1.2-beta h1:fDg7rYUmqO1UJ3SqvDDEB7Wc0kDjpzgS81VGhcJTkoI=
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you see why this beta dependency is there?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Ran go mod tidy.

github.com/google/sqlcommenter/go/core v0.1.2-beta/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