MCPcopy Create free account
hub / github.com/PostHog/duckgres / TestEncodeBytea

Function TestEncodeBytea

server/types_test.go:465–495  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

463}
464
465func TestEncodeBytea(t *testing.T) {
466 tests := []struct {
467 name string
468 input interface{}
469 expected []byte
470 }{
471 {"byte slice", []byte{0x01, 0x02, 0x03}, []byte{0x01, 0x02, 0x03}},
472 {"empty byte slice", []byte{}, []byte{}},
473 {"string", "hello", []byte("hello")},
474 }
475
476 for _, tt := range tests {
477 t.Run(tt.name, func(t *testing.T) {
478 result := encodeBytea(tt.input)
479 if len(result) != len(tt.expected) {
480 t.Errorf("encodeBytea(%v) length = %d, want %d", tt.input, len(result), len(tt.expected))
481 return
482 }
483 for i, b := range result {
484 if b != tt.expected[i] {
485 t.Errorf("encodeBytea(%v)[%d] = %d, want %d", tt.input, i, b, tt.expected[i])
486 }
487 }
488 })
489 }
490
491 // Test unsupported type returns nil
492 if result := encodeBytea(12345); result != nil {
493 t.Errorf("encodeBytea(int) should return nil")
494 }
495}
496
497func TestEncodeBinary(t *testing.T) {
498 // Test that encodeBinary dispatches to the correct encoder

Callers

nothing calls this directly

Calls 2

encodeByteaFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected