summaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace/src/github.com/lib/pq/url_test.go
diff options
context:
space:
mode:
author=Corey Hulen <corey@hulen.com>2015-07-12 14:56:44 -0800
committer=Corey Hulen <corey@hulen.com>2015-07-12 14:56:44 -0800
commit1c493317857e729597bb59fc0878b49106257582 (patch)
tree9c69d95de082e22279b30d66034e20cb1e9875c3 /Godeps/_workspace/src/github.com/lib/pq/url_test.go
parent95b9f872882b367556ca2330eea8c8309db542e6 (diff)
downloadchat-1c493317857e729597bb59fc0878b49106257582.tar.gz
chat-1c493317857e729597bb59fc0878b49106257582.tar.bz2
chat-1c493317857e729597bb59fc0878b49106257582.zip
Fixes mm-1420 adding postgres support
Diffstat (limited to 'Godeps/_workspace/src/github.com/lib/pq/url_test.go')
-rw-r--r--Godeps/_workspace/src/github.com/lib/pq/url_test.go54
1 files changed, 54 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/lib/pq/url_test.go b/Godeps/_workspace/src/github.com/lib/pq/url_test.go
new file mode 100644
index 000000000..29f4a7c75
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/lib/pq/url_test.go
@@ -0,0 +1,54 @@
+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 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)
+ }
+}