Sfoglia il codice sorgente

add a test to verify we get unsupported protocol error

Chris Bannister 9 anni fa
parent
commit
cfa0c47011
1 ha cambiato i file con 16 aggiunte e 0 eliminazioni
  1. 16 0
      cassandra_test.go

+ 16 - 0
cassandra_test.go

@@ -2413,3 +2413,19 @@ func TestSchemaReset(t *testing.T) {
 		t.Errorf("expected to get val=%q got=%q", expVal, val)
 	}
 }
+
+func TestCreateSession_DontSwallowError(t *testing.T) {
+	cluster := createCluster()
+	cluster.ProtoVersion = 100
+	session, err := cluster.CreateSession()
+	if err == nil {
+		session.Close()
+
+		t.Fatal("expected to get an error for unsupported protocol")
+	}
+	// TODO: we should get a distinct error type here which include the underlying
+	// cassandra error about the protocol version, for now check this here.
+	if !strings.Contains(err.Error(), "Invalid or unsupported protocol version (100)") {
+		t.Fatalf("expcted to get error unsupported protocol version got: %v", err)
+	}
+}