summaryrefslogtreecommitdiffstats
path: root/dependencies/pkg/mod/github.com/lib/pq@v1.10.7/uuid_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/uuid_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 'dependencies/pkg/mod/github.com/lib/pq@v1.10.7/uuid_test.go')
-rw-r--r--dependencies/pkg/mod/github.com/lib/pq@v1.10.7/uuid_test.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/dependencies/pkg/mod/github.com/lib/pq@v1.10.7/uuid_test.go b/dependencies/pkg/mod/github.com/lib/pq@v1.10.7/uuid_test.go
new file mode 100644
index 0000000..8ecee2f
--- /dev/null
+++ b/dependencies/pkg/mod/github.com/lib/pq@v1.10.7/uuid_test.go
@@ -0,0 +1,46 @@
+package pq
+
+import (
+ "reflect"
+ "strings"
+ "testing"
+)
+
+func TestDecodeUUIDBinaryError(t *testing.T) {
+ t.Parallel()
+ _, err := decodeUUIDBinary([]byte{0x12, 0x34})
+
+ if err == nil {
+ t.Fatal("Expected error, got none")
+ }
+ if !strings.HasPrefix(err.Error(), "pq:") {
+ t.Errorf("Expected error to start with %q, got %q", "pq:", err.Error())
+ }
+ if !strings.Contains(err.Error(), "bad length: 2") {
+ t.Errorf("Expected error to contain length, got %q", err.Error())
+ }
+}
+
+func BenchmarkDecodeUUIDBinary(b *testing.B) {
+ x := []byte{0x03, 0xa3, 0x52, 0x2f, 0x89, 0x28, 0x49, 0x87, 0x84, 0xd6, 0x93, 0x7b, 0x36, 0xec, 0x27, 0x6f}
+
+ for i := 0; i < b.N; i++ {
+ decodeUUIDBinary(x)
+ }
+}
+
+func TestDecodeUUIDBackend(t *testing.T) {
+ db := openTestConn(t)
+ defer db.Close()
+
+ var s = "a0ecc91d-a13f-4fe4-9fce-7e09777cc70a"
+ var scanned interface{}
+
+ err := db.QueryRow(`SELECT $1::uuid`, s).Scan(&scanned)
+ if err != nil {
+ t.Fatalf("Expected no error, got %v", err)
+ }
+ if !reflect.DeepEqual(scanned, []byte(s)) {
+ t.Errorf("Expected []byte(%q), got %T(%q)", s, scanned, scanned)
+ }
+}