func Test_Localhost(t *testing.T) { opts := command.Options{ Host: "localhost", Port: 5432, User: "******", Pass: "******", DbName: "db", } str, err := BuildString(opts) assert.Equal(t, nil, err) assert.Equal(t, "postgres://*****:*****@localhost:5432/db?sslmode=disable", str) opts.Host = "127.0.0.1" str, err = BuildString(opts) assert.Equal(t, nil, err) assert.Equal(t, "postgres://*****:*****@127.0.0.1:5432/db?sslmode=disable", str) }