go.undefinedlabs.com/scopeagent@v0.4.2/instrumentation/sql/vendor_postgres_test.go (about)

     1  package sql
     2  
     3  import "testing"
     4  
     5  func TestPostgresDSNParser(t *testing.T) {
     6  	ext := &postgresExtension{}
     7  	dConf := &driverConfiguration{}
     8  
     9  	ext.ProcessConnectionString("host=localhost port=5432 user=testUser password=testPassword dbname=dbname", dConf)
    10  
    11  	if dConf.user != "testUser" {
    12  		t.Fatal("User invalid.")
    13  	}
    14  	if dConf.port != "5432" {
    15  		t.Fatal("Port invalid.")
    16  	}
    17  	if dConf.instance != "dbname" {
    18  		t.Fatal("Instance invalid.")
    19  	}
    20  	if dConf.host != "localhost" {
    21  		t.Fatal("Host invalid.")
    22  	}
    23  	if dConf.connString != "host=localhost port=5432 user=testUser password=****** dbname=dbname" {
    24  		t.Fatalf("Connection string invalid, expected: %s, actual: %s",
    25  			"host=localhost port=5432 user=testUser password=****** dbname=dbname",
    26  			dConf.connString)
    27  	}
    28  }