Add test to check that LastInsertId() returns an error.

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/aeb6fc39
Tree: http://git-wip-us.apache.org/repos/asf/calcite-avatica-go/tree/aeb6fc39
Diff: http://git-wip-us.apache.org/repos/asf/calcite-avatica-go/diff/aeb6fc39

Branch: refs/heads/master
Commit: aeb6fc39af507e22a8feb7bc089b64ed0adb71b6
Parents: 7b12e40
Author: Francis Chuang <francis.chu...@gmail.com>
Authored: Mon May 30 16:17:51 2016 +1000
Committer: Julian Hyde <jh...@apache.org>
Committed: Thu Aug 10 18:47:08 2017 -0700

----------------------------------------------------------------------
 driver_test.go | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite-avatica-go/blob/aeb6fc39/driver_test.go
----------------------------------------------------------------------
diff --git a/driver_test.go b/driver_test.go
index cf12fd0..62dfd89 100644
--- a/driver_test.go
+++ b/driver_test.go
@@ -810,3 +810,30 @@ func TestOptimisticConcurrency(t *testing.T) {
                }
        })
 }
+
+func TestLastInsertIDShouldReturnError(t *testing.T) {
+
+       runTests(t, dsn, func(dbt *DBTest) {
+
+               // Create and seed table
+               dbt.mustExec(`CREATE TABLE test (
+                               id INTEGER PRIMARY KEY,
+                               msg VARCHAR,
+                               version INTEGER
+                           ) TRANSACTIONAL=true`)
+
+               dbt.mustExec(`CREATE SEQUENCE test.test_sequence`)
+
+               res, err := dbt.db.Exec(`UPSERT INTO test VALUES(NEXT VALUE FOR 
test.test_sequence, 'abc', 1)`)
+
+               if err != nil {
+                       dbt.Fatal(err)
+               }
+
+               _, err = res.LastInsertId()
+
+               if err == nil {
+                       dbt.Fatal("Expected an error as Avatica does not 
support LastInsertId(), but there was no error.")
+               }
+       })
+}

Reply via email to