summaryrefslogtreecommitdiffstats
path: root/dependencies/pkg/mod/github.com/lib/pq@v1.10.7/url_test.go
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:36:04 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:36:04 +0000
commitb09c6d56832eb1718c07d74abf3bc6ae3fe4e030 (patch)
treed2caec2610d4ea887803ec9e9c3cd77136c448ba /dependencies/pkg/mod/github.com/lib/pq@v1.10.7/url_test.go
parentInitial commit. (diff)
downloadicingadb-b09c6d56832eb1718c07d74abf3bc6ae3fe4e030.tar.xz
icingadb-b09c6d56832eb1718c07d74abf3bc6ae3fe4e030.zip
Adding upstream version 1.1.0.upstream/1.1.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--dependencies/pkg/mod/github.com/lib/pq@v1.10.7/url_test.go66
1 files changed, 66 insertions, 0 deletions
diff --git a/dependencies/pkg/mod/github.com/lib/pq@v1.10.7/url_test.go b/dependencies/pkg/mod/github.com/lib/pq@v1.10.7/url_test.go
new file mode 100644
index 0000000..9b63455
--- /dev/null
+++ b/dependencies/pkg/mod/github.com/lib/pq@v1.10.7/url_test.go
@@ -0,0 +1,66 @@
+package pq
+
+import (
+ "testing"
+)
+
+func TestSimpleParseURL(t *testing.T) {
+ expected := "host='hostname.remote'"
+ str, err := ParseURL("postgres://hostname.remote")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if str != expected {
+ t.Fatalf("unexpected result from ParseURL:\n+ %v\n- %v", str, expected)
+ }
+}
+
+func TestIPv6LoopbackParseURL(t *testing.T) {
+ expected := "host='::1' port='1234'"
+ str, err := ParseURL("postgres://[::1]:1234")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if str != expected {
+ t.Fatalf("unexpected result from ParseURL:\n+ %v\n- %v", str, expected)
+ }
+}
+
+func TestFullParseURL(t *testing.T) {
+ expected := `dbname='database' host='hostname.remote' password='top secret' port='1234' user='username'`
+ str, err := ParseURL("postgres://username:top%20secret@hostname.remote:1234/database")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if str != expected {
+ t.Fatalf("unexpected result from ParseURL:\n+ %s\n- %s", str, expected)
+ }
+}
+
+func TestInvalidProtocolParseURL(t *testing.T) {
+ _, err := ParseURL("http://hostname.remote")
+ switch err {
+ case nil:
+ t.Fatal("Expected an error from parsing invalid protocol")
+ default:
+ msg := "invalid connection protocol: http"
+ if err.Error() != msg {
+ t.Fatalf("Unexpected error message:\n+ %s\n- %s",
+ err.Error(), msg)
+ }
+ }
+}
+
+func TestMinimalURL(t *testing.T) {
+ cs, err := ParseURL("postgres://")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if cs != "" {
+ t.Fatalf("expected blank connection string, got: %q", cs)
+ }
+}