Browse Source

Fix iter Host method (#2) (#918)

* Fix iter Host method
Raphael Gavache 8 years ago
parent
commit
ca7d339566
3 changed files with 14 additions and 0 deletions
  1. 1 0
      AUTHORS
  2. 12 0
      cassandra_test.go
  3. 1 0
      query_executor.go

+ 1 - 0
AUTHORS

@@ -88,3 +88,4 @@ Jesse Claven <jesse.claven@gmail.com>
 Derrick Wippler <thrawn01@gmail.com>
 Leigh McCulloch <leigh@leighmcculloch.com>
 Ron Kuris <swcafe@gmail.com>
+Raphael Gavache <raphael.gavache@gmail.com>

+ 12 - 0
cassandra_test.go

@@ -1580,6 +1580,18 @@ func TestQueryStats(t *testing.T) {
 	}
 }
 
+// TestIterHosts confirms that host is added to Iter when the query succeeds.
+func TestIterHost(t *testing.T) {
+	session := createSession(t)
+	defer session.Close()
+	iter := session.Query("SELECT * FROM system.peers").Iter()
+
+	// check if Host method works
+	if iter.Host() == nil {
+		t.Error("No host in iter")
+	}
+}
+
 //TestBatchStats confirms that the stats are returning valid data. Accuracy may be questionable.
 func TestBatchStats(t *testing.T) {
 	if *flagProto == 1 {

+ 1 - 0
query_executor.go

@@ -48,6 +48,7 @@ func (q *queryExecutor) executeQuery(qry ExecutableQuery) (*Iter, error) {
 
 		// Exit for loop if the query was successful
 		if iter.err == nil {
+			iter.host = host
 			return iter, nil
 		}