Browse Source

tests: use discovered protocol not flag proto to enable udt tests

Chris Bannister 8 years ago
parent
commit
7113222558
2 changed files with 29 additions and 29 deletions
  1. 1 1
      common_test.go
  2. 28 28
      udt_test.go

+ 1 - 1
common_test.go

@@ -13,7 +13,7 @@ import (
 
 var (
 	flagCluster      = flag.String("cluster", "127.0.0.1", "a comma-separated list of host:port tuples")
-	flagProto        = flag.Int("proto", 2, "protcol version")
+	flagProto        = flag.Int("proto", 0, "protcol version")
 	flagCQL          = flag.String("cql", "3.0.0", "CQL version")
 	flagRF           = flag.Int("rf", 1, "replication factor for test keyspace")
 	clusterSize      = flag.Int("clusterSize", 1, "the expected size of the cluster")

+ 28 - 28
udt_test.go

@@ -44,13 +44,13 @@ func (p *position) UnmarshalUDT(name string, info TypeInfo, data []byte) error {
 }
 
 func TestUDT_Marshaler(t *testing.T) {
-	if *flagProto < protoVersion3 {
-		t.Skip("UDT are only available on protocol >= 3")
-	}
-
 	session := createSession(t)
 	defer session.Close()
 
+	if session.cfg.ProtoVersion < protoVersion3 {
+		t.Skip("UDT are only available on protocol >= 3")
+	}
+
 	err := createTable(session, `CREATE TYPE gocql_test.position(
 		lat int,
 		lon int,
@@ -100,14 +100,14 @@ func TestUDT_Marshaler(t *testing.T) {
 }
 
 func TestUDT_Reflect(t *testing.T) {
-	if *flagProto < protoVersion3 {
-		t.Skip("UDT are only available on protocol >= 3")
-	}
-
 	// Uses reflection instead of implementing the marshaling type
 	session := createSession(t)
 	defer session.Close()
 
+	if session.cfg.ProtoVersion < protoVersion3 {
+		t.Skip("UDT are only available on protocol >= 3")
+	}
+
 	err := createTable(session, `CREATE TYPE gocql_test.horse(
 		name text,
 		owner text);`)
@@ -160,13 +160,13 @@ func TestUDT_Proto2error(t *testing.T) {
 }
 
 func TestUDT_NullObject(t *testing.T) {
-	if *flagProto < protoVersion3 {
-		t.Skip("UDT are only available on protocol >= 3")
-	}
-
 	session := createSession(t)
 	defer session.Close()
 
+	if session.cfg.ProtoVersion < protoVersion3 {
+		t.Skip("UDT are only available on protocol >= 3")
+	}
+
 	err := createTable(session, `CREATE TYPE gocql_test.udt_null_type(
 		name text,
 		owner text);`)
@@ -214,13 +214,13 @@ func TestUDT_NullObject(t *testing.T) {
 }
 
 func TestMapScanUDT(t *testing.T) {
-	if *flagProto < protoVersion3 {
-		t.Skip("UDT are only available on protocol >= 3")
-	}
-
 	session := createSession(t)
 	defer session.Close()
 
+	if session.cfg.ProtoVersion < protoVersion3 {
+		t.Skip("UDT are only available on protocol >= 3")
+	}
+
 	err := createTable(session, `CREATE TYPE gocql_test.log_entry (
 		created_timestamp timestamp,
 		message text
@@ -351,13 +351,13 @@ func TestUDT_MissingField(t *testing.T) {
 }
 
 func TestUDT_EmptyCollections(t *testing.T) {
-	if *flagProto < protoVersion3 {
-		t.Skip("UDT are only available on protocol >= 3")
-	}
-
 	session := createSession(t)
 	defer session.Close()
 
+	if session.cfg.ProtoVersion < protoVersion3 {
+		t.Skip("UDT are only available on protocol >= 3")
+	}
+
 	err := createTable(session, `CREATE TYPE gocql_test.nil_collections(
 		a list<text>,
 		b map<text, text>,
@@ -407,13 +407,13 @@ func TestUDT_EmptyCollections(t *testing.T) {
 }
 
 func TestUDT_UpdateField(t *testing.T) {
-	if *flagProto < protoVersion3 {
-		t.Skip("UDT are only available on protocol >= 3")
-	}
-
 	session := createSession(t)
 	defer session.Close()
 
+	if session.cfg.ProtoVersion < protoVersion3 {
+		t.Skip("UDT are only available on protocol >= 3")
+	}
+
 	err := createTable(session, `CREATE TYPE gocql_test.update_field_udt(
 		name text,
 		owner text);`)
@@ -464,13 +464,13 @@ func TestUDT_UpdateField(t *testing.T) {
 }
 
 func TestUDT_ScanNullUDT(t *testing.T) {
-	if *flagProto < protoVersion3 {
-		t.Skip("UDT are only available on protocol >= 3")
-	}
-
 	session := createSession(t)
 	defer session.Close()
 
+	if session.cfg.ProtoVersion < protoVersion3 {
+		t.Skip("UDT are only available on protocol >= 3")
+	}
+
 	err := createTable(session, `CREATE TYPE gocql_test.scan_null_udt_position(
 		lat int,
 		lon int,