Skip to content

Commit

Permalink
Added test to ensure library can properly decode error response from …
Browse files Browse the repository at this point in the history
…cassandra
  • Loading branch information
nemosupremo committed May 1, 2014
1 parent ebd7b8e commit 0e247a0
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions errors_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package gocql

import (
"testing"
)

func TestErrorsParse(t *testing.T) {
session := createSession(t)
defer session.Close()

if err := session.Query(`CREATE TABLE errors_parse (id int primary key)`).Exec(); err != nil {
t.Fatal("create:", err)
}

if err := session.Query(`CREATE TABLE errors_parse (id int primary key)`).Exec(); err == nil {
t.Fatal("Should have gotten already exists error from cassandra server.")
} else {
switch e := err.(type) {
case errRespAlreadyExists:
if e.Table != "errors_parse" {
t.Fatal("Failed to parse error response from cassandra for ErrAlreadyExists.")
}
default:
t.Fatal("Failed to parse error response from cassandra for ErrAlreadyExists.")
}
}
}

0 comments on commit 0e247a0

Please sign in to comment.