File: errors_test.go

package info (click to toggle)
golang-github-gocql-gocql 0.0~git20191102.0.9faa4c0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,012 kB
  • sloc: sh: 84; makefile: 2
file content (29 lines) | stat: -rw-r--r-- 753 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// +build all cassandra

package gocql

import (
	"testing"
)

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

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

	if err := createTable(session, `CREATE TABLE gocql_test.errors_parse (id int primary key)`); err == nil {
		t.Fatal("Should have gotten already exists error from cassandra server.")
	} else {
		switch e := err.(type) {
		case *RequestErrAlreadyExists:
			if e.Table != "errors_parse" {
				t.Fatalf("expected error table to be 'errors_parse' but was %q", e.Table)
			}
		default:
			t.Fatalf("expected to get RequestErrAlreadyExists instead got %T", e)
		}
	}
}