Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package embeddedpostgres

import (
"fmt"
"io"
"os"
"time"
Expand Down Expand Up @@ -118,6 +119,10 @@ func (c Config) BinaryRepositoryURL(binaryRepositoryURL string) Config {
return c
}

func (c Config) GetConnectionURL() string {
return fmt.Sprintf("postgresql://%s:%s@%s:%d/%s", c.username, c.password, "localhost", c.port, c.database)
}

// PostgresVersion represents the semantic version used to fetch and run the Postgres process.
type PostgresVersion string

Expand Down
12 changes: 12 additions & 0 deletions test_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package embeddedpostgres

import "testing"

func TestGetConnectionURL(t *testing.T) {
config := DefaultConfig().Database("mydb").Username("myuser").Password("mypass")
expect := "postgresql://myuser:mypass@localhost:5432/mydb"

if got := config.GetConnectionURL(); got != expect {
t.Errorf("expected \"%s\" got \"%s\"", expect, got)
}
}