2
0

Handle ValueTranscoder EncodeTo returns error on bad type

Instead of panicking
This commit is contained in:
Jack Christensen
2014-06-19 08:03:14 -05:00
parent 5fe3dd7ecf
commit 884252675e
4 changed files with 144 additions and 33 deletions
+21
View File
@@ -5,6 +5,27 @@ import (
"time"
)
func TestTranscodeError(t *testing.T) {
conn := getSharedConnection(t)
mustPrepare(t, conn, "testTranscode", "select $1::integer")
defer func() {
if err := conn.Deallocate("testTranscode"); err != nil {
t.Fatalf("Unable to deallocate prepared statement: %v", err)
}
}()
_, err := conn.SelectValue("testTranscode", "wrong")
switch {
case err == nil:
t.Error("Expected transcode error to return error, but it didn't")
case err.Error() == "Expected int32, received string":
// Correct behavior
default:
t.Errorf("Expected transcode error, received %v", err)
}
}
func TestNilTranscode(t *testing.T) {
conn := getSharedConnection(t)