go.undefinedlabs.com/scopeagent@v0.4.2/instrumentation/sql/vendor_mysql_test.go (about) 1 package sql 2 3 import ( 4 "os" 5 "testing" 6 7 "go.undefinedlabs.com/scopeagent" 8 ) 9 10 func TestMain(m *testing.M) { 11 os.Exit(scopeagent.Run(m)) 12 } 13 14 func TestMySqlDSNParser(t *testing.T) { 15 ext := &mysqlExtension{} 16 dConf := &driverConfiguration{} 17 18 ext.ProcessConnectionString("testUser:testPassword@tcp(localhost:3306)/dbname", dConf) 19 20 if dConf.user != "testUser" { 21 t.Fatal("User invalid.") 22 } 23 if dConf.port != "3306" { 24 t.Fatal("Port invalid.") 25 } 26 if dConf.instance != "dbname" { 27 t.Fatal("Instance invalid.") 28 } 29 if dConf.host != "localhost" { 30 t.Fatal("Host invalid.") 31 } 32 if dConf.connString != "testUser:******@tcp(localhost:3306)/dbname" { 33 t.Fatalf("Connection string invalid, expected: %s, actual: %s", 34 "testUser:******@tcp(localhost:3306)/dbname", 35 dConf.connString) 36 } 37 }