44 "context"
55 "database/sql/driver"
66 "encoding/json"
7+ "github.com/stretchr/testify/require"
78 "testing"
89
910 "github.com/google/uuid"
@@ -19,11 +20,11 @@ func TestMakeHeadersUserPassword(t *testing.T) {
1920 sessionState : & SessionState {Role : "role1" },
2021 }
2122 headers , err := c .makeHeaders (context .Background ())
22- assert .Nil (t , err )
23- assert .Equal (t , headers [ "Authorization" ], [] string {"Basic cm9vdDpyb290" })
24- assert .Equal (t , headers ["X-Databend-Tenant" ], [] string { "default" } )
23+ assert .NoError (t , err )
24+ assert .Equal (t , [] string {"Basic cm9vdDpyb290" }, headers [ "Authorization" ] )
25+ assert .Equal (t , [] string { "default" }, headers ["X-Databend-Tenant" ])
2526 session := c .getSessionState ()
26- assert .Equal (t , session . Role , "role1" )
27+ assert .Equal (t , "role1" , session . Role )
2728}
2829
2930func TestMakeHeadersAccessToken (t * testing.T ) {
@@ -35,10 +36,10 @@ func TestMakeHeadersAccessToken(t *testing.T) {
3536 }
3637 ctx := checkQueryID (context .Background ())
3738 headers , err := c .makeHeaders (ctx )
38- assert .Nil (t , err )
39- assert .Equal (t , headers [ "Authorization" ], [] string {"Bearer abc123" })
40- assert .Equal (t , headers ["X-Databend-Tenant" ], [] string { "tn3ftqihs" } )
41- assert .Equal (t , headers [ "X-Databend-Warehouse" ], [] string {"small-abc" })
39+ assert .NoError (t , err )
40+ assert .Equal (t , [] string {"Bearer abc123" }, headers [ "Authorization" ] )
41+ assert .Equal (t , [] string { "tn3ftqihs" }, headers ["X-Databend-Tenant" ])
42+ assert .Equal (t , [] string {"small-abc" }, headers [ "X-Databend-Warehouse" ] )
4243 assert .NotEmptyf (t , headers ["X-Databend-Query-Id" ], "Query ID is not empty" )
4344}
4445
@@ -67,8 +68,8 @@ func TestMakeHeadersQueryID(t *testing.T) {
6768 queryId := uuid .NewString ()
6869 ctx := context .WithValue (context .Background (), ContextKeyQueryID , queryId )
6970 headers , err := c .makeHeaders (ctx )
70- assert . Nil (t , err )
71- assert .Equal (t , headers ["X-Databend-Query-Id" ], [] string { queryId } )
71+ require . NoError (t , err )
72+ assert .Equal (t , [] string { queryId }, headers ["X-Databend-Query-Id" ])
7273}
7374
7475func TestDoQuery (t * testing.T ) {
@@ -98,6 +99,6 @@ func TestDoQuery(t *testing.T) {
9899 ctx := context .WithValue (context .Background (), ContextKeyQueryID , queryId )
99100 resp , err := c .StartQuery (ctx , "SELECT 1" , []driver.Value {})
100101 assert .NoError (t , err )
101- assert .Equal (t , gotQueryID , "mockid1" )
102+ assert .Equal (t , "mockid1" , gotQueryID )
102103 assert .Equal (t , resp .ID , queryId )
103104}
0 commit comments