Browse Source

Added a test to verify the bug described by #191

Ben Hood 11 years ago
parent
commit
13dd738da1
1 changed files with 15 additions and 0 deletions
  1. 15 0
      cassandra_test.go

+ 15 - 0
cassandra_test.go

@@ -307,6 +307,21 @@ func TestBatchLimit(t *testing.T) {
 
 
 }
 }
 
 
+// TestWrongQueryArgsLength tests to make sure the library correctly handles the application level bug
+// whereby the wrong number of query arguments are passed to a query
+func TestWrongQueryArgsLength(t *testing.T) {
+	session := createSession(t)
+	defer session.Close()
+
+	if err := session.Query(`CREATE TABLE query_args_length (id int primary key, value int)`).Exec(); err != nil {
+		t.Fatal("create table:", err)
+	}
+
+	if _, err := session.Query(`SELECT * FROM query_args_length WHERE id = ?`, 1, 2).Iter().SliceMap(); err != nil {
+		t.Fatal("select query_args_length:", err)
+	}
+}
+
 // TestCreateSessionTimeout tests to make sure the CreateSession function timeouts out correctly
 // TestCreateSessionTimeout tests to make sure the CreateSession function timeouts out correctly
 // and prevents an infinite loop of connection retries.
 // and prevents an infinite loop of connection retries.
 func TestCreateSessionTimeout(t *testing.T) {
 func TestCreateSessionTimeout(t *testing.T) {