cassanity 0.5.1 → 0.6.0.beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +1 -1
  3. data/README.md +3 -16
  4. data/cassanity.gemspec +3 -1
  5. data/examples/keyspaces.rb +2 -2
  6. data/lib/cassanity/argument_generators/column_families.rb +1 -1
  7. data/lib/cassanity/argument_generators/columns.rb +2 -2
  8. data/lib/cassanity/argument_generators/keyspace_create.rb +4 -21
  9. data/lib/cassanity/argument_generators/with_clause.rb +2 -9
  10. data/lib/cassanity/client.rb +16 -13
  11. data/lib/cassanity/executors/{cassandra_cql.rb → cql_rb.rb} +28 -11
  12. data/lib/cassanity/keyspace.rb +7 -22
  13. data/lib/cassanity/migrator.rb +2 -2
  14. data/lib/cassanity/result_transformers/column_families.rb +1 -1
  15. data/lib/cassanity/result_transformers/columns.rb +2 -2
  16. data/lib/cassanity/result_transformers/keyspaces.rb +1 -1
  17. data/lib/cassanity/result_transformers/result_to_array.rb +1 -5
  18. data/lib/cassanity/retry_strategies/retry_strategy.rb +3 -3
  19. data/lib/cassanity/statement.rb +58 -0
  20. data/lib/cassanity/version.rb +1 -1
  21. data/spec/helper.rb +2 -4
  22. data/spec/integration/cassanity/column_family_spec.rb +62 -64
  23. data/spec/integration/cassanity/connection_spec.rb +2 -8
  24. data/spec/integration/cassanity/instrumentation/log_subscriber_spec.rb +4 -1
  25. data/spec/integration/cassanity/instrumentation/metriks_subscriber_spec.rb +2 -1
  26. data/spec/integration/cassanity/instrumentation/statsd_subscriber_spec.rb +2 -1
  27. data/spec/integration/cassanity/keyspace_spec.rb +1 -1
  28. data/spec/integration/cassanity/migration_spec.rb +5 -5
  29. data/spec/integration/cassanity/migrator_spec.rb +4 -4
  30. data/spec/support/cassanity_helpers.rb +7 -5
  31. data/spec/unit/cassanity/argument_generators/column_families_spec.rb +1 -1
  32. data/spec/unit/cassanity/argument_generators/columns_spec.rb +3 -3
  33. data/spec/unit/cassanity/argument_generators/keyspace_create_spec.rb +12 -16
  34. data/spec/unit/cassanity/argument_generators/with_clause_spec.rb +5 -6
  35. data/spec/unit/cassanity/client_spec.rb +15 -53
  36. data/spec/unit/cassanity/connection_spec.rb +6 -6
  37. data/spec/unit/cassanity/keyspace_spec.rb +12 -14
  38. data/spec/unit/cassanity/result_transformers/result_to_array_spec.rb +3 -16
  39. data/spec/unit/cassanity/statement_spec.rb +100 -0
  40. metadata +35 -24
  41. data/spec/unit/cassanity/executors/cassandra_cql_spec.rb +0 -286
@@ -6,7 +6,7 @@ describe Cassanity::ColumnFamily do
6
6
  let(:column_family_name) { :apps }
7
7
  let(:counters_column_family_name) { :counters }
8
8
 
9
- let(:client) { Cassanity::Client.new(CassanityServers) }
9
+ let(:client) { Cassanity::Client.new(CassanityHost, CassanityPort) }
10
10
  let(:driver) { client.driver }
11
11
 
12
12
  let(:keyspace) { client[keyspace_name] }
@@ -66,27 +66,30 @@ describe Cassanity::ColumnFamily do
66
66
  column_family = described_class.new(arguments.merge(name: 'people'))
67
67
  column_family.create
68
68
 
69
- column_families = driver.schema.column_families
70
- apps_column_family = column_families.fetch(column_family.name.to_s)
71
- apps_column_family.comment.should eq('For storing things')
69
+ families = driver.execute("SELECT * from system.schema_columnfamilies WHERE keyspace_name='#{driver.keyspace}' AND columnfamily_name='people' ALLOW FILTERING")
70
+ people_column_family = families.first
71
+ people_column_family['comment'].should eq('For storing things')
72
72
 
73
- columns = apps_column_family.columns
74
- columns.should have_key('id')
75
- columns.should have_key('name')
76
- columns['id'].should eq('org.apache.cassandra.db.marshal.TimeUUIDType')
77
- columns['name'].should eq('org.apache.cassandra.db.marshal.UTF8Type')
73
+ columns = driver.execute("SELECT * from system.schema_columns WHERE keyspace_name='#{driver.keyspace}' AND columnfamily_name='people' ALLOW FILTERING")
74
+ id = columns.detect { |c| c['column_name'] == 'id' }
75
+ id.should_not be_nil
76
+ id['validator'].should eq('org.apache.cassandra.db.marshal.TimeUUIDType')
77
+
78
+ name = columns.detect { |c| c['column_name'] == 'name' }
79
+ name.should_not be_nil
80
+ name['validator'].should eq('org.apache.cassandra.db.marshal.UTF8Type')
78
81
  end
79
82
 
80
83
  it "can truncate" do
81
- driver.execute("INSERT INTO #{column_family_name} (id, name) VALUES (?, ?)", '1', 'github')
82
- driver.execute("INSERT INTO #{column_family_name} (id, name) VALUES (?, ?)", '2', 'gist')
84
+ driver.execute("INSERT INTO #{column_family_name} (id, name) VALUES ('1', 'github')")
85
+ driver.execute("INSERT INTO #{column_family_name} (id, name) VALUES ('2', 'gist')")
83
86
  result = driver.execute("SELECT * FROM #{column_family_name}")
84
- result.rows.should eq(2)
87
+ result.to_a.length.should eq(2)
85
88
 
86
89
  subject.truncate
87
90
 
88
91
  result = driver.execute("SELECT * FROM #{column_family_name}")
89
- result.rows.should eq(0)
92
+ result.to_a.length.should eq(0)
90
93
  end
91
94
 
92
95
  it "can drop" do
@@ -103,33 +106,30 @@ describe Cassanity::ColumnFamily do
103
106
  end
104
107
 
105
108
  it "can alter" do
106
- subject.alter(add: {created_at: :timestamp})
109
+ subject.alter(add: {some_text: :text})
107
110
 
108
- column_families = driver.schema.column_families
109
- apps_column_family = column_families.fetch(column_family_name.to_s)
110
- columns = apps_column_family.columns
111
- columns.should have_key('created_at')
112
- columns['created_at'].should eq('org.apache.cassandra.db.marshal.DateType')
111
+ columns = driver.execute("SELECT * from system.schema_columns WHERE keyspace_name='#{driver.keyspace}' AND columnfamily_name='apps' ALLOW FILTERING")
112
+ some_text = columns.detect { |c| c['column_name'] == 'some_text' }
113
+ some_text.should_not be_nil
114
+ some_text['validator'].should eq('org.apache.cassandra.db.marshal.UTF8Type')
113
115
 
114
- subject.alter(alter: {created_at: :timeuuid})
116
+ subject.alter(alter: {some_text: :blob})
115
117
 
116
- column_families = driver.schema.column_families
117
- apps_column_family = column_families.fetch(column_family_name.to_s)
118
- columns = apps_column_family.columns
119
- columns.should have_key('created_at')
120
- columns['created_at'].should eq('org.apache.cassandra.db.marshal.TimeUUIDType')
118
+ columns = driver.execute("SELECT * from system.schema_columns WHERE keyspace_name='#{driver.keyspace}' AND columnfamily_name='apps' ALLOW FILTERING")
119
+ some_text = columns.detect { |c| c['column_name'] == 'some_text' }
120
+ some_text.should_not be_nil
121
+ some_text['validator'].should eq('org.apache.cassandra.db.marshal.BytesType')
121
122
 
122
- subject.alter(drop: :created_at)
123
+ subject.alter(drop: :some_text)
123
124
 
124
- column_families = driver.schema.column_families
125
- apps_column_family = column_families.fetch(column_family_name.to_s)
126
- columns = apps_column_family.columns
127
- columns.should_not have_key('created_at')
125
+ columns = driver.execute("SELECT * from system.schema_columns WHERE keyspace_name='#{driver.keyspace}' AND columnfamily_name='apps' ALLOW FILTERING")
126
+ some_text = columns.detect { |c| c['column_name'] == 'some_text' }
127
+ some_text.should be_nil
128
128
 
129
129
  subject.alter(with: {comment: 'Some new comment'})
130
- column_families = driver.schema.column_families
131
- apps_column_family = column_families.fetch(column_family_name.to_s)
132
- apps_column_family.comment.should eq('Some new comment')
130
+ families = driver.execute("SELECT * from system.schema_columnfamilies WHERE keyspace_name='#{driver.keyspace}' AND columnfamily_name='apps' ALLOW FILTERING")
131
+ apps_column_family = families.first
132
+ apps_column_family['comment'].should eq('Some new comment')
133
133
  end
134
134
 
135
135
  it "can create and drop indexes" do
@@ -138,24 +138,22 @@ describe Cassanity::ColumnFamily do
138
138
  column_name: :name,
139
139
  })
140
140
 
141
- apps = driver.schema.column_families.fetch(column_family_name.to_s)
142
- apps_meta = apps.column_metadata
143
- index = apps_meta.detect { |c| c.index_name == 'apps_name_index' }
141
+ columns = driver.execute("SELECT * from system.schema_columns WHERE keyspace_name='#{driver.keyspace}' AND columnfamily_name='apps' ALLOW FILTERING")
142
+ index = columns.detect { |c| c['index_name'] == 'apps_name_index' }
144
143
  index.should_not be_nil
145
144
 
146
145
  subject.drop_index({
147
146
  name: :apps_name_index,
148
147
  })
149
148
 
150
- apps = driver.schema.column_families.fetch(column_family_name.to_s)
151
- apps_meta = apps.column_metadata
152
- index = apps_meta.detect { |c| c.index_name == 'apps_name_index' }
149
+ columns = driver.execute("SELECT * from system.schema_columns WHERE keyspace_name='#{driver.keyspace}' AND columnfamily_name='apps' ALLOW FILTERING")
150
+ index = columns.detect { |c| c['index_name'] == 'apps_name_index' }
153
151
  index.should be_nil
154
152
  end
155
153
 
156
154
  it "can select data" do
157
- driver.execute("INSERT INTO #{column_family_name} (id, name) VALUES (?, ?)", '1', 'github')
158
- driver.execute("INSERT INTO #{column_family_name} (id, name) VALUES (?, ?)", '2', 'gist')
155
+ driver.execute("INSERT INTO #{column_family_name} (id, name) VALUES ('1', 'github')")
156
+ driver.execute("INSERT INTO #{column_family_name} (id, name) VALUES ('2', 'gist')")
159
157
  result = subject.select({
160
158
  select: :name,
161
159
  where: {
@@ -180,10 +178,10 @@ describe Cassanity::ColumnFamily do
180
178
  before do
181
179
  driver.execute("CREATE COLUMNFAMILY #{name} (id text, ts int, value counter, PRIMARY KEY(id, ts))")
182
180
  @id = 'foo'
183
- driver.execute("UPDATE #{name} SET value = value + 1 WHERE id = ? AND ts = ?", @id, 1)
184
- driver.execute("UPDATE #{name} SET value = value + 1 WHERE id = ? AND ts = ?", @id, 2)
185
- driver.execute("UPDATE #{name} SET value = value + 1 WHERE id = ? AND ts = ?", @id, 3)
186
- driver.execute("UPDATE #{name} SET value = value + 1 WHERE id = ? AND ts = ?", @id, 4)
181
+ driver.execute("UPDATE #{name} SET value = value + 1 WHERE id = '#@id' AND ts = 1")
182
+ driver.execute("UPDATE #{name} SET value = value + 1 WHERE id = '#@id' AND ts = 2")
183
+ driver.execute("UPDATE #{name} SET value = value + 1 WHERE id = '#@id' AND ts = 3")
184
+ driver.execute("UPDATE #{name} SET value = value + 1 WHERE id = '#@id' AND ts = 4")
187
185
  end
188
186
 
189
187
  it "works including end" do
@@ -221,15 +219,15 @@ describe Cassanity::ColumnFamily do
221
219
  })
222
220
 
223
221
  result = driver.execute("SELECT * FROM #{column_family_name}")
224
- result.rows.should eq(1)
225
- row = result.fetch_hash
222
+ result.to_a.length.should eq(1)
223
+ row = result.first
226
224
  row['id'].should eq('1')
227
225
  row['name'].should eq('GitHub')
228
226
  end
229
227
 
230
228
  it "can update data" do
231
- driver.execute("INSERT INTO #{column_family_name} (id, name) VALUES (?, ?)", '1', 'github')
232
- driver.execute("INSERT INTO #{column_family_name} (id, name) VALUES (?, ?)", '2', 'gist')
229
+ driver.execute("INSERT INTO #{column_family_name} (id, name) VALUES ('1', 'github')")
230
+ driver.execute("INSERT INTO #{column_family_name} (id, name) VALUES ('2', 'gist')")
233
231
 
234
232
  subject.update({
235
233
  set: {name: 'New Name'},
@@ -237,15 +235,15 @@ describe Cassanity::ColumnFamily do
237
235
  })
238
236
 
239
237
  result = driver.execute("SELECT * FROM #{column_family_name} WHERE id = '1'")
240
- result.rows.should eq(1)
241
- row = result.fetch_hash
238
+ result.to_a.length.should eq(1)
239
+ row = result.first
242
240
  row['id'].should eq('1')
243
241
  row['name'].should eq('New Name')
244
242
 
245
243
  # does not update other rows
246
244
  result = driver.execute("SELECT * FROM #{column_family_name} WHERE id = '2'")
247
- result.rows.should eq(1)
248
- row = result.fetch_hash
245
+ result.to_a.length.should eq(1)
246
+ row = result.first
249
247
  row['id'].should eq('2')
250
248
  row['name'].should eq('gist')
251
249
  end
@@ -265,8 +263,8 @@ describe Cassanity::ColumnFamily do
265
263
  })
266
264
 
267
265
  result = driver.execute("SELECT * FROM #{counters_column_family_name} WHERE id = '1'")
268
- result.rows.should eq(1)
269
- row = result.fetch_hash
266
+ result.to_a.length.should eq(1)
267
+ row = result.first
270
268
  row['id'].should eq('1')
271
269
  row['views'].should be(2)
272
270
  end
@@ -287,35 +285,35 @@ describe Cassanity::ColumnFamily do
287
285
  })
288
286
 
289
287
  result = driver.execute("SELECT * FROM #{counters_column_family_name} WHERE id = '1'")
290
- result.rows.should eq(1)
291
- row = result.fetch_hash
288
+ result.to_a.length.should eq(1)
289
+ row = result.first
292
290
  row['id'].should eq('1')
293
291
  row['views'].should be(-2)
294
292
  end
295
293
  end
296
294
 
297
295
  it "can delete data" do
298
- driver.execute("INSERT INTO #{column_family_name} (id, name) VALUES (?, ?)", '1', 'github')
299
- driver.execute("INSERT INTO #{column_family_name} (id, name) VALUES (?, ?)", '2', 'gist')
296
+ driver.execute("INSERT INTO #{column_family_name} (id, name) VALUES ('1', 'github')")
297
+ driver.execute("INSERT INTO #{column_family_name} (id, name) VALUES ('2', 'gist')")
300
298
 
301
299
  result = driver.execute("SELECT * FROM #{column_family_name}")
302
- result.rows.should eq(2)
300
+ result.to_a.length.should eq(2)
303
301
 
304
302
  subject.delete({
305
303
  where: {id: '1'},
306
304
  })
307
305
 
308
306
  result = driver.execute("SELECT * FROM #{column_family_name} WHERE id = '1'")
309
- result.rows.should eq(0)
307
+ result.to_a.length.should eq(0)
310
308
 
311
309
  # does not delete other rows
312
310
  result = driver.execute("SELECT * FROM #{column_family_name} WHERE id = '2'")
313
- result.rows.should eq(1)
311
+ result.to_a.length.should eq(1)
314
312
  end
315
313
 
316
314
  it "can get columns" do
317
315
  columns = subject.columns
318
- columns.map(&:name).should eq([:name])
319
- columns.map(&:type).should eq([:text])
316
+ columns.map(&:name).should eq([:id, :name])
317
+ columns.map(&:type).should eq([:text, :text])
320
318
  end
321
319
  end
@@ -1,12 +1,11 @@
1
1
  require 'helper'
2
2
  require 'cassanity/connection'
3
- require 'cassanity/executors/cassandra_cql'
4
3
 
5
4
  describe Cassanity::Connection do
6
5
  let(:keyspace_name) { 'cassanity_test' }
7
6
  let(:column_family_name) { 'apps' }
8
7
 
9
- let(:client) { Cassanity::Client.new(CassanityServers) }
8
+ let(:client) { Cassanity::Client.new(CassanityHost, CassanityPort) }
10
9
  let(:driver) { client.driver }
11
10
 
12
11
  subject { client.connection }
@@ -35,12 +34,7 @@ describe Cassanity::Connection do
35
34
  })
36
35
 
37
36
  result = driver.execute("SELECT * FROM apps")
38
- result.rows.should be(1)
39
-
40
- rows = []
41
- result.fetch_hash { |row| rows << row }
42
-
43
- rows.should eq([
37
+ result.to_a.should eq([
44
38
  {'id' => '1', 'name' => 'github.com'},
45
39
  ])
46
40
  end
@@ -1,9 +1,12 @@
1
1
  require 'helper'
2
+ require 'logger'
3
+ require 'stringio'
4
+ require 'simple_uuid'
2
5
  require 'cassanity/instrumentation/log_subscriber'
3
6
 
4
7
  describe Cassanity::Instrumentation::LogSubscriber do
5
8
  let(:client) {
6
- Cassanity::Client.new(CassanityServers, {
9
+ Cassanity::Client.new(CassanityHost, CassanityPort, {
7
10
  instrumenter: ActiveSupport::Notifications,
8
11
  })
9
12
  }
@@ -1,9 +1,10 @@
1
1
  require 'helper'
2
+ require 'simple_uuid'
2
3
  require 'cassanity/instrumentation/metriks'
3
4
 
4
5
  describe Cassanity::Instrumentation::MetriksSubscriber do
5
6
  let(:client) {
6
- Cassanity::Client.new(CassanityServers, {
7
+ Cassanity::Client.new(CassanityHost, CassanityPort, {
7
8
  instrumenter: ActiveSupport::Notifications,
8
9
  })
9
10
  }
@@ -1,4 +1,5 @@
1
1
  require 'helper'
2
+ require 'simple_uuid'
2
3
  require 'cassanity/instrumentation/statsd'
3
4
 
4
5
  describe Cassanity::Instrumentation::StatsdSubscriber do
@@ -6,7 +7,7 @@ describe Cassanity::Instrumentation::StatsdSubscriber do
6
7
  let(:socket) { FakeUDPSocket.new }
7
8
 
8
9
  let(:client) {
9
- Cassanity::Client.new(CassanityServers, {
10
+ Cassanity::Client.new(CassanityHost, CassanityPort, {
10
11
  instrumenter: ActiveSupport::Notifications,
11
12
  })
12
13
  }
@@ -6,7 +6,7 @@ describe Cassanity::Keyspace do
6
6
  let(:self_created_keyspace_name) { 'self_created' }
7
7
  let(:column_family_name) { 'apps' }
8
8
 
9
- let(:client) { Cassanity::Client.new(CassanityServers) }
9
+ let(:client) { Cassanity::Client.new(CassanityHost, CassanityPort) }
10
10
  let(:driver) { client.driver }
11
11
 
12
12
  let(:required_arguments) {
@@ -2,7 +2,7 @@ require 'helper'
2
2
  require 'cassanity/migrator'
3
3
 
4
4
  describe Cassanity::Migration do
5
- let(:client) { Cassanity::Client.new(CassanityServers) }
5
+ let(:client) { Cassanity::Client.new(CassanityHost, CassanityPort) }
6
6
  let(:driver) { client.driver }
7
7
  let(:keyspace) { client[:cassanity_test] }
8
8
  let(:migrator) { Cassanity::Migrator.new(keyspace, '/fake') }
@@ -127,8 +127,8 @@ describe Cassanity::Migration do
127
127
  end
128
128
 
129
129
  it "adds index" do
130
- meta = driver.schema.column_families['users'].column_metadata
131
- index = meta.detect { |c| c.index_name == 'users_email_index' }
130
+ columns = driver.execute("SELECT * from system.schema_columns WHERE keyspace_name='#{driver.keyspace}' AND columnfamily_name='users' ALLOW FILTERING")
131
+ index = columns.detect { |c| c['index_name'] == 'users_email_index' }
132
132
  index.should_not be_nil
133
133
  end
134
134
  end
@@ -149,8 +149,8 @@ describe Cassanity::Migration do
149
149
  end
150
150
 
151
151
  it "drops index" do
152
- meta = driver.schema.column_families['users'].column_metadata
153
- index = meta.detect { |c| c.index_name == 'users_email_index' }
152
+ columns = driver.execute("SELECT * from system.schema_columns WHERE keyspace_name='#{driver.keyspace}' AND columnfamily_name='users' ALLOW FILTERING")
153
+ index = columns.detect { |c| c['index_name'] == 'users_email_index' }
154
154
  index.should be_nil
155
155
  end
156
156
  end
@@ -2,7 +2,7 @@ require 'helper'
2
2
  require 'cassanity/migrator'
3
3
 
4
4
  describe Cassanity::Migrator do
5
- let(:client) { Cassanity::Client.new(CassanityServers) }
5
+ let(:client) { Cassanity::Client.new(CassanityHost, CassanityPort) }
6
6
  let(:driver) { client.driver }
7
7
  let(:keyspace) { client[:cassanity_test] }
8
8
  let(:column_family) { subject.column_family }
@@ -147,7 +147,7 @@ describe Cassanity::Migrator do
147
147
  it "removes migration from performed migrations" do
148
148
  migration = subject.migrations[0]
149
149
  subject.column_family.insert(data: {
150
- version: migration.version,
150
+ version: migration.version.to_s,
151
151
  name: migration.name,
152
152
  migrated_at: Time.now,
153
153
  })
@@ -173,7 +173,7 @@ describe Cassanity::Migrator do
173
173
  subject.migrations.each do |migration|
174
174
  subject.column_family.insert(data: {
175
175
  name: migration.name,
176
- version: migration.version,
176
+ version: migration.version.to_s,
177
177
  migrated_at: Time.now,
178
178
  })
179
179
  end
@@ -192,7 +192,7 @@ describe Cassanity::Migrator do
192
192
  migration = subject.migrations[0]
193
193
  subject.column_family.insert(data: {
194
194
  name: migration.name,
195
- version: migration.version,
195
+ version: migration.version.to_s,
196
196
  migrated_at: Time.now,
197
197
  })
198
198
  names = subject.pending_migrations.map(&:name)
@@ -1,13 +1,14 @@
1
1
  module CassanityHelpers
2
2
  def driver_keyspace?(driver, name)
3
- driver.keyspaces.map(&:name).include?(name.to_s)
3
+ rows = driver.execute("SELECT keyspace_name FROM system.schema_keyspaces WHERE keyspace_name='#{name}' ALLOW FILTERING")
4
+ rows.to_a.any?
4
5
  end
5
6
 
6
7
  def driver_create_keyspace(driver, name)
7
8
  unless driver_keyspace?(driver, name)
8
- driver.execute("CREATE KEYSPACE #{name} WITH strategy_class = 'SimpleStrategy' AND strategy_options:replication_factor = 1")
9
+ driver.execute("CREATE KEYSPACE #{name} WITH REPLICATION = { 'class': 'SimpleStrategy', 'replication_factor': 1 }")
9
10
  end
10
- driver.execute("USE #{name}")
11
+ driver.use(name)
11
12
  end
12
13
 
13
14
  def driver_drop_keyspace(driver, name)
@@ -17,7 +18,8 @@ module CassanityHelpers
17
18
  end
18
19
 
19
20
  def driver_column_family?(driver, name)
20
- driver.schema.column_family_names.include?(name.to_s)
21
+ rows = driver.execute("SELECT columnfamily_name FROM system.schema_columnfamilies WHERE keyspace_name='#{driver.keyspace}' AND columnfamily_name='#{name}' ALLOW FILTERING")
22
+ rows.to_a.any?
21
23
  end
22
24
 
23
25
  def driver_create_column_family(driver, name, columns = nil)
@@ -34,6 +36,6 @@ module CassanityHelpers
34
36
  end
35
37
 
36
38
  def cassandra_error(err)
37
- CassandraCQL::Error::InvalidRequestException.new(err)
39
+ Cql::CqlError.new(err)
38
40
  end
39
41
  end
@@ -13,7 +13,7 @@ describe Cassanity::ArgumentGenerators::ColumnFamilies do
13
13
 
14
14
  context "with :keyspace_name" do
15
15
  it "returns array of arguments for selecting all column families for keyspace" do
16
- cql = 'SELECT * FROM system.schema_columnfamilies WHERE "keyspace" = ?'
16
+ cql = 'SELECT * FROM system.schema_columnfamilies WHERE "keyspace_name" = ?'
17
17
  variables = ['foo']
18
18
  expected = [cql, 'foo']
19
19
  subject.call(keyspace_name: 'foo').should eq(expected)
@@ -13,7 +13,7 @@ describe Cassanity::ArgumentGenerators::Columns do
13
13
 
14
14
  context "with keyspace" do
15
15
  it "returns array of arguments for selecting all columns for keyspace" do
16
- cql = 'SELECT * FROM system.schema_columns WHERE "keyspace" = ?'
16
+ cql = 'SELECT * FROM system.schema_columns WHERE "keyspace_name" = ?'
17
17
  expected = [cql, 'foo']
18
18
  subject.call({
19
19
  keyspace_name: 'foo',
@@ -23,7 +23,7 @@ describe Cassanity::ArgumentGenerators::Columns do
23
23
 
24
24
  context "with column family" do
25
25
  it "returns array of arguments for selecting all columns for column family" do
26
- cql = 'SELECT * FROM system.schema_columns WHERE "columnfamily" = ?'
26
+ cql = 'SELECT * FROM system.schema_columns WHERE "columnfamily_name" = ?'
27
27
  expected = [cql, 'foo']
28
28
  subject.call({
29
29
  column_family_name: 'foo',
@@ -33,7 +33,7 @@ describe Cassanity::ArgumentGenerators::Columns do
33
33
 
34
34
  context "with keyspace and column family" do
35
35
  it "returns array of arguments for selecting all columns for a column family in a keyspace" do
36
- cql = 'SELECT * FROM system.schema_columns WHERE "keyspace" = ? AND "columnfamily" = ?'
36
+ cql = 'SELECT * FROM system.schema_columns WHERE "keyspace_name" = ? AND "columnfamily_name" = ?'
37
37
  expected = [cql, 'foo', 'bar']
38
38
  subject.call({
39
39
  keyspace_name: 'foo',
@@ -7,45 +7,41 @@ describe Cassanity::ArgumentGenerators::KeyspaceCreate do
7
7
  describe "#call" do
8
8
  context "only name" do
9
9
  it "returns array of arguments" do
10
- cql = "CREATE KEYSPACE #{keyspace_name} WITH strategy_class = ? AND strategy_options:replication_factor = ?"
11
- expected = [cql, 'SimpleStrategy', 1]
10
+ cql = "CREATE KEYSPACE #{keyspace_name} WITH replication = ?"
11
+ expected = [cql, {class: 'SimpleStrategy', replication_factor: 1}]
12
12
  subject.call(keyspace_name: keyspace_name).should eq(expected)
13
13
  end
14
14
  end
15
15
 
16
- context "overriding strategy_class" do
16
+ context "overriding replication class" do
17
17
  it "returns array of arguments" do
18
- cql = "CREATE KEYSPACE #{keyspace_name} WITH strategy_class = ? AND strategy_options:replication_factor = ?"
19
- expected = [cql, 'FooStrategy', 1]
18
+ cql = "CREATE KEYSPACE #{keyspace_name} WITH replication = ?"
19
+ expected = [cql, {class: 'FooStrategy', replication_factor: 1}]
20
20
  subject.call({
21
21
  keyspace_name: keyspace_name,
22
- strategy_class: 'FooStrategy',
22
+ replication: {class: 'FooStrategy'},
23
23
  }).should eq(expected)
24
24
  end
25
25
  end
26
26
 
27
27
  context "overriding a default strategy_option" do
28
28
  it "returns array of arguments" do
29
- cql = "CREATE KEYSPACE #{keyspace_name} WITH strategy_class = ? AND strategy_options:replication_factor = ?"
30
- expected = [cql, 'SimpleStrategy', 3]
29
+ cql = "CREATE KEYSPACE #{keyspace_name} WITH replication = ?"
30
+ expected = [cql, {class: 'SimpleStrategy', replication_factor: 3}]
31
31
  subject.call({
32
32
  keyspace_name: keyspace_name,
33
- strategy_options: {
34
- replication_factor: 3,
35
- }
33
+ replication: {replication_factor: 3},
36
34
  }).should eq(expected)
37
35
  end
38
36
  end
39
37
 
40
38
  context "adding new strategy_option" do
41
39
  it "returns array of arguments" do
42
- cql = "CREATE KEYSPACE #{keyspace_name} WITH strategy_class = ? AND strategy_options:replication_factor = ? AND strategy_options:batman = ?"
43
- expected = [cql, 'SimpleStrategy', 1, 'robin']
40
+ cql = "CREATE KEYSPACE #{keyspace_name} WITH replication = ?"
41
+ expected = [cql, {class: 'SimpleStrategy', replication_factor: 1, batman: 'robin'}]
44
42
  subject.call({
45
43
  keyspace_name: keyspace_name,
46
- strategy_options: {
47
- batman: 'robin',
48
- }
44
+ replication: {batman: 'robin'},
49
45
  }).should eq(expected)
50
46
  end
51
47
  end
@@ -61,15 +61,14 @@ describe Cassanity::ArgumentGenerators::WithClause do
61
61
  it "returns array of arguments" do
62
62
  subject.call({
63
63
  with: {
64
- compaction_strategy_options: {
65
- min_compaction_threshold: 6,
66
- max_compaction_threshold: 40,
64
+ replication: {
65
+ class: 'SimpleStrategy',
66
+ replication_factor: 3,
67
67
  },
68
68
  }
69
69
  }).should eq([
70
- " WITH compaction_strategy_options:min_compaction_threshold = ? AND compaction_strategy_options:max_compaction_threshold = ?",
71
- 6,
72
- 40,
70
+ " WITH replication = ?",
71
+ { class: 'SimpleStrategy', replication_factor: 3 },
73
72
  ])
74
73
  end
75
74
  end