Improve tests to fix copy() and catch errors when asserting

Project: http://git-wip-us.apache.org/repos/asf/calcite-avatica-go/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/calcite-avatica-go/commit/e9f8bda3
Tree: http://git-wip-us.apache.org/repos/asf/calcite-avatica-go/tree/e9f8bda3
Diff: http://git-wip-us.apache.org/repos/asf/calcite-avatica-go/diff/e9f8bda3

Branch: refs/heads/master
Commit: e9f8bda39b23b7cdc04124a73a44d2c9da70b634
Parents: 472802b
Author: Francis Chuang <francis.chu...@boostport.com>
Authored: Sat Jun 17 13:59:42 2017 +1000
Committer: Julian Hyde <jh...@apache.org>
Committed: Thu Aug 10 18:47:11 2017 -0700

----------------------------------------------------------------------
 driver_test.go | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite-avatica-go/blob/e9f8bda3/driver_test.go
----------------------------------------------------------------------
diff --git a/driver_test.go b/driver_test.go
index f2035f7..c77601e 100644
--- a/driver_test.go
+++ b/driver_test.go
@@ -229,7 +229,7 @@ func TestDataTypes(t *testing.T) {
                        varbinValue   []byte    = []byte("testtesttest")
                )
 
-               copy(binValue[:], "test")
+               copy(binValue[:], []byte("test"))
 
                dbt.mustExec(`UPSERT INTO `+dbt.tableName+` VALUES (?, ?, ?, ?, 
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
                        integerValue,
@@ -1044,7 +1044,11 @@ func TestErrorCodeParsing(t *testing.T) {
                t.Error("Expected error due to selecting from non-existent 
table, but there was no error.")
        }
 
-       resErr := err.(ResponseError)
+       resErr, ok := err.(ResponseError)
+
+       if !ok {
+               t.Fatalf("Error type was not ResponseError")
+       }
 
        if resErr.ErrorCode != 1012 {
                t.Errorf("Expected error code to be %d, got %d.", 1012, 
resErr.ErrorCode)

Reply via email to