Skip to content

Commit

Permalink
Test invalid keyspace
Browse files Browse the repository at this point in the history
  • Loading branch information
willfaught committed Apr 5, 2016
1 parent 9b034c7 commit 75d0514
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion session.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func metadata(s *gocql.Session, keyspace string) (*gocql.KeyspaceMetadata, error
return nil, err
}

if m.DurableWrites && m.Name == keyspace && m.StrategyClass == "" && m.StrategyOptions == nil && m.Tables == nil {
if !m.DurableWrites && m.Name == keyspace && m.StrategyClass == "" && len(m.StrategyOptions) == 0 && len(m.Tables) == 0 {
return nil, fmt.Errorf("gockle: keyspace %v invalid", keyspace)
}

Expand Down
4 changes: 4 additions & 0 deletions session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ func TestSessionMetadata(t *testing.T) {
t.Fatalf("Actual error %v, expected no error", err)
}

if _, err := s.Tables("gockle_test_invalid"); err == nil {
t.Errorf("Actual no error, expected error")
}

s.Close()

if _, err := s.Tables("gockle_test"); err == nil {
Expand Down

0 comments on commit 75d0514

Please sign in to comment.