linkage 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,336 +2,36 @@ require 'helper'
2
2
 
3
3
  class UnitTests::TestDataset < Test::Unit::TestCase
4
4
  def setup
5
- @database = stub("database")
6
- Sequel.stubs(:connect).yields(@database)
5
+ super
7
6
  @schema = [
8
7
  [:id, {:allow_null=>true, :default=>nil, :primary_key=>true, :db_type=>"integer", :type=>:integer, :ruby_default=>nil}],
9
8
  [:first_name, {:allow_null=>true, :default=>nil, :primary_key=>false, :db_type=>"varchar(255)", :type=>:string, :ruby_default=>nil}],
10
9
  [:last_name, {:allow_null=>true, :default=>nil, :primary_key=>false, :db_type=>"varchar(255)", :type=>:string, :ruby_default=>nil}]
11
10
  ]
12
- @database.stubs(:schema).returns(@schema)
13
- @dataset = stub("dataset")
14
- @database.stubs(:[]).returns(@dataset)
15
-
16
- @id_field = stub("id field", :dataset= => nil, :name => :id)
17
- Linkage::Field.stubs(:new).with(:id, kind_of(Hash)).returns(@id_field)
18
- @first_name_field = stub("first_name field", :dataset= => nil, :name => :first_name, :to_expr => :first_name)
19
- Linkage::Field.stubs(:new).with(:first_name, kind_of(Hash)).returns(@first_name_field)
20
- @last_name_field = stub("last_name field", :dataset= => nil, :name => :last_name, :to_expr => :last_name)
21
- Linkage::Field.stubs(:new).with(:last_name, kind_of(Hash)).returns(@last_name_field)
22
- end
23
-
24
- def expr(&block)
25
- Sequel.virtual_row(&block)
11
+ @dataset = stub('Sequel dataset')
12
+ @database = stub('database', :schema => @schema, :[] => @dataset)
13
+ Sequel.stubs(:connect).returns(@database)
14
+ @field_set = stub("field set")
15
+ Linkage::FieldSet.stubs(:new).returns(@field_set)
26
16
  end
27
17
 
28
18
  test "initialize with uri and table name" do
29
- Sequel.expects(:connect).with("foo:/bar", {}).yields(@database)
30
- @database.expects(:schema).with(:baz).returns(@schema)
31
- primary_key_field = mock(:dataset= => nil)
32
- Linkage::Field.expects(:new).with(*@schema[0]).returns(primary_key_field)
33
- Linkage::Field.expects(:new).with(*@schema[1]).returns(mock(:dataset= => nil))
34
- Linkage::Field.expects(:new).with(*@schema[2]).returns(mock(:dataset= => nil))
35
-
36
- ds = Linkage::Dataset.new("foo:/bar", "baz")
37
- assert_equal primary_key_field, ds.primary_key
38
- end
39
-
40
- test "initialize with sequel options" do
41
- Sequel.expects(:connect).with("foo:/bar", :junk => 123).yields(@database)
42
- ds = Linkage::Dataset.new("foo:/bar", "baz", :junk => 123)
43
- end
44
-
45
- test "dataset id increments" do
46
- dataset_1 = Linkage::Dataset.new("foo:/bar", "baz")
47
- assert_kind_of Fixnum, dataset_1.id
48
- dataset_2 = Linkage::Dataset.new("foo:/qux", "corge")
49
- assert_equal dataset_1.id + 1, dataset_2.id
50
- end
51
-
52
- test "== compares uri and table name" do
53
- dataset_1 = Linkage::Dataset.new("foo:/bar", "baz")
54
- dataset_2 = Linkage::Dataset.new("foo:/bar", "baz")
55
- dataset_3 = Linkage::Dataset.new("foo:/qux", "corge")
56
- assert_equal dataset_1, dataset_2
57
- assert_not_equal dataset_1, dataset_3
58
- end
59
-
60
- test "dup" do
61
- dataset_1 = Linkage::Dataset.new("foo:/bar", "baz")
62
-
63
- ds = stub('new dataset')
64
- Linkage::Dataset.expects(:new).with('foo:/bar', :baz).returns(ds)
65
- dataset_2 = dataset_1.dup
66
- assert_equal ds, dataset_2
67
- end
68
-
69
- test "clone doesn't shallow copy fields" do
70
- field_1 = stub('field 1', :name => :id, :dataset= => nil)
71
- Linkage::Field.expects(:new).with(*@schema[0]).returns(field_1)
72
- field_2 = stub('field 2', :dataset= => nil)
73
- Linkage::Field.expects(:new).with(*@schema[1]).returns(field_2)
74
- field_3 = stub('field 3', :dataset= => nil)
75
- Linkage::Field.expects(:new).with(*@schema[2]).returns(field_3)
76
- dataset_1 = Linkage::Dataset.new("foo:/bar", "baz")
77
-
78
- field_1.expects(:clone).returns(mock('field 1 clone', :dataset= => nil))
79
- field_2.expects(:clone).returns(mock('field 2 clone', :dataset= => nil))
80
- field_3.expects(:clone).returns(mock('field 3 clone', :dataset= => nil))
81
- dataset_2 = dataset_1.clone
82
- dataset_2.fields.each_pair do |name, field|
83
- assert !field.equal?(dataset_1.fields[name])
84
- end
85
- assert !dataset_2.primary_key.equal?(dataset_1.primary_key)
86
- assert_equal dataset_1.id, dataset_2.id
87
- end
88
-
89
- test "clone doesn't shallow copy @order" do
90
- dataset_1 = Linkage::Dataset.new("foo:/bar", "baz")
91
- dataset_2 = dataset_1.clone
92
- dataset_1.add_order(@first_name_field)
93
- assert_empty dataset_2.instance_variable_get(:@order)
94
- end
95
-
96
- test "clone doesn't shallow copy @select" do
97
- dataset_1 = Linkage::Dataset.new("foo:/bar", "baz")
98
- dataset_2 = dataset_1.clone
99
- dataset_1.add_select(@first_name_field)
100
- assert_empty dataset_2.instance_variable_get(:@select)
101
- end
102
-
103
- test "clone doesn't shallow copy @filter" do
104
- dataset_1 = Linkage::Dataset.new("foo:/bar", "baz")
105
- dataset_2 = dataset_1.clone
106
- dataset_1.add_filter(@first_name_field, :==, "foo")
107
- assert_empty dataset_2.instance_variable_get(:@filter)
108
- end
109
-
110
- test "add_order with field, then each" do
111
- field = stub_field('field', :name => :last_name, :to_expr => :last_name)
112
- ds = Linkage::Dataset.new("foo:/bar", "baz")
113
- ds.add_order(field)
114
- @dataset.expects(:order).with(:last_name).returns(@dataset)
115
- row = {:id => 123, :last_name => 'foo'}
116
- @dataset.expects(:each).yields(row)
117
-
118
- ran = false
119
- ds.each do |yielded_row|
120
- ran = true
121
- assert_equal({:pk => 123, :values => {:last_name => 'foo'}}, yielded_row)
122
- end
123
- assert ran
124
- end
125
-
126
- test "add_order with function, then each" do
127
- expr = stub('expression')
128
- func = stub_function('func', :name => :trim_stuff, :to_expr => expr)
129
- ds = Linkage::Dataset.new("foo:/bar", "baz")
130
- ds.add_order(func)
131
- @dataset.expects(:order).with(expr).returns(@dataset)
132
- row = {:id => 123, :trim_stuff => 'foo'}
133
- @dataset.expects(:each).yields(row)
134
-
135
- ran = false
136
- ds.each do |yielded_row|
137
- ran = true
138
- assert_equal({:pk => 123, :values => {:trim_stuff => 'foo'}}, yielded_row)
139
- end
140
- assert ran
141
- end
142
-
143
- test "add_order descending, then each" do
144
- field = stub_field('field', :name => :last_name, :to_expr => :last_name)
145
- ds = Linkage::Dataset.new("foo:/bar", "baz")
146
- ds.add_order(field, :desc)
147
- @dataset.expects(:order).with(:last_name.desc).returns(@dataset)
148
- row = {:id => 123, :last_name => 'foo'}
149
- @dataset.expects(:each).yields(row)
150
-
151
- ran = false
152
- ds.each do |yielded_row|
153
- ran = true
154
- assert_equal({:pk => 123, :values => {:last_name => 'foo'}}, yielded_row)
155
- end
156
- assert ran
157
- end
158
-
159
- test "add_order weeds out field duplicates" do
160
- field = stub_field('field', :name => :last_name, :to_expr => :last_name)
161
- ds = Linkage::Dataset.new("foo:/bar", "baz")
162
- ds.add_order(field)
163
- ds.add_order(field)
164
- @dataset.expects(:order).with(:last_name).returns(@dataset)
165
- @dataset.expects(:each)
166
- ds.each { }
167
- end
168
-
169
- test "add_order weeds out function duplicates" do
170
- expr = stub('expression')
171
- func = stub_function('func', :name => :trim_stuff, :to_expr => expr)
172
- ds = Linkage::Dataset.new("foo:/bar", "baz")
173
- ds.add_order(func)
174
- ds.add_order(func)
175
- @dataset.expects(:order).with(expr).returns(@dataset)
176
- @dataset.expects(:each)
177
- ds.each { }
178
- end
179
-
180
- test "add_select with field, then each" do
181
- field = stub_field('field', :name => :last_name, :to_expr => :last_name)
182
- ds = Linkage::Dataset.new("foo:/bar", "baz")
183
- ds.add_select(field)
184
- @dataset.expects(:select).with(:id, :last_name).returns(@dataset)
185
- row = {:id => 123, :last_name => 'foo'}
186
- @dataset.expects(:each).yields(row)
187
-
188
- ran = false
189
- ds.each do |yielded_row|
190
- ran = true
191
- assert_equal({:pk => 123, :values => {:last_name => 'foo'}}, yielded_row)
192
- end
193
- assert ran
194
- end
195
-
196
- test "add_select with an alias, then each" do
197
- field = stub_field('field', :name => :last_name, :to_expr => :last_name)
198
- ds = Linkage::Dataset.new("foo:/bar", "baz")
199
- ds.add_select(field, :junk)
200
- @dataset.expects(:select).with(:id, :last_name.as(:junk)).returns(@dataset)
201
- row = {:id => 123, :junk => 'foo'}
202
- @dataset.expects(:each).yields(row)
203
-
204
- ran = false
205
- ds.each do |yielded_row|
206
- ran = true
207
- assert_equal({:pk => 123, :values => {:junk => 'foo'}}, yielded_row)
208
- end
209
- assert ran
210
- end
211
-
212
- test "add_select with function, then each" do
213
- expr = stub('expression')
214
- func = stub_function('func', :name => :trim_stuff, :to_expr => expr)
215
- ds = Linkage::Dataset.new("foo:/bar", "baz")
216
- ds.add_select(func)
217
- @dataset.expects(:select).with(:id, expr).returns(@dataset)
218
- row = {:id => 123, :trim_stuff => 'foo'}
219
- @dataset.expects(:each).yields(row)
220
-
221
- ran = false
222
- ds.each do |yielded_row|
223
- ran = true
224
- assert_equal({:pk => 123, :values => {:trim_stuff => 'foo'}}, yielded_row)
225
- end
226
- assert ran
227
- end
228
-
229
- test "add_select weeds out duplicates" do
230
- field = stub_field('field', :name => :last_name, :to_expr => :last_name)
231
- ds = Linkage::Dataset.new("foo:/bar", "baz")
232
- ds.add_select(field)
233
- ds.add_select(field)
234
- @dataset.expects(:select).with(:id, :last_name).returns(@dataset)
235
- @dataset.expects(:each)
236
- ds.each { }
237
- end
238
-
239
- test "add_filter with :== between field and static value, then each" do
240
- field = stub('field', :name => :age, :to_expr => :age)
241
- ds = Linkage::Dataset.new("foo:/bar", "baz")
242
- ds.add_filter(field, :==, 30)
243
- @dataset.expects(:filter).with(:age => 30).returns(@dataset)
244
- row = {:id => 123, :junk => 'foo'}
245
- @dataset.expects(:each).yields(row)
246
-
247
- ran = false
248
- ds.each do |yielded_row|
249
- ran = true
250
- assert_equal({:pk => 123, :values => {:junk => 'foo'}}, yielded_row)
251
- end
252
- assert ran
253
- end
254
-
255
- test "add_filter with :== between field and static function, then each" do
256
- field = stub_field('field', :name => :age, :to_expr => :age)
257
- expr = stub('expression')
258
- func = stub_function('func', :name => :func, :to_expr => expr)
259
- ds = Linkage::Dataset.new("foo:/bar", "baz")
260
- ds.add_filter(field, :==, func)
261
- @dataset.expects(:filter).with(:age => expr).returns(@dataset)
262
- row = {:id => 123, :junk => 'foo'}
263
- @dataset.expects(:each).yields(row)
264
-
265
- ran = false
266
- ds.each do |yielded_row|
267
- ran = true
268
- assert_equal({:pk => 123, :values => {:junk => 'foo'}}, yielded_row)
269
- end
270
- assert ran
271
- end
272
-
273
- test "add_filter with :== between two fields, then each" do
274
- field_1 = stub_field('field 1', :name => :foo, :to_expr => :foo)
275
- field_2 = stub_field('field 2', :name => :bar, :to_expr => :bar)
276
- ds = Linkage::Dataset.new("foo:/bar", "baz")
277
- ds.add_filter(field_1, :==, field_2)
278
- @dataset.expects(:filter).with(:foo => :bar).returns(@dataset)
279
- @dataset.expects(:each)
280
- ds.each { }
281
- end
282
-
283
- test "add_filter with :>, then each" do
284
- field = stub('field', :name => :age, :to_expr => :age)
285
- ds = Linkage::Dataset.new("foo:/bar", "baz")
286
- ds.add_filter(field, :>, 30)
287
- @dataset.expects(:filter).with(expr{age > 30}).returns(@dataset)
288
- @dataset.expects(:each)
289
- ds.each { }
290
- end
291
-
292
- test "add_filter with :<, then each" do
293
- field = stub_field('field', :name => :age, :to_expr => :age)
294
- ds = Linkage::Dataset.new("foo:/bar", "baz")
295
- ds.add_filter(field, :<, 30)
296
- @dataset.expects(:filter).with(expr{age < 30}).returns(@dataset)
297
- @dataset.expects(:each)
298
- ds.each { }
299
- end
300
-
301
- test "add_filter with :>=, then each" do
302
- field = stub_field('field', :name => :age, :to_expr => :age)
303
- ds = Linkage::Dataset.new("foo:/bar", "baz")
304
- ds.add_filter(field, :>=, 30)
305
- @dataset.expects(:filter).with(expr{age >= 30}).returns(@dataset)
306
- @dataset.expects(:each)
307
- ds.each { }
308
- end
309
-
310
- test "add_filter with :<=, then each" do
311
- field = stub('field', :name => :age, :to_expr => :age)
312
- ds = Linkage::Dataset.new("foo:/bar", "baz")
313
- ds.add_filter(field, :<=, 30)
314
- @dataset.expects(:filter).with(expr{age <= 30}).returns(@dataset)
315
- @dataset.expects(:each)
316
- ds.each { }
19
+ Sequel.expects(:connect).with('foo:/bar', {:foo => 'bar'}).returns(@database)
20
+ @database.expects(:schema).with(:foo).returns(@schema)
21
+ @database.expects(:[]).with(:foo).returns(@dataset)
22
+ Linkage::FieldSet.expects(:new).with(@schema).returns(@field_set)
23
+ ds = Linkage::Dataset.new('foo:/bar', "foo", {:foo => 'bar'})
317
24
  end
318
25
 
319
- test "add_filter with :!=, then each" do
320
- field = stub_field('field', :name => :age, :to_expr => :age)
321
- ds = Linkage::Dataset.new("foo:/bar", "baz")
322
- ds.add_filter(field, :'!=', 30)
323
- @dataset.expects(:filter).with(~{:age => 30}).returns(@dataset)
324
- @dataset.expects(:each)
325
- ds.each { }
26
+ test "table_name" do
27
+ ds = Linkage::Dataset.new('foo:/bar', "foo", {:foo => 'bar'})
28
+ assert_equal :foo, ds.table_name
326
29
  end
327
30
 
328
- test "add_filter with :> field, then each" do
329
- field_1 = stub_field('field 1', :name => :age, :to_expr => :age)
330
- field_2 = stub_field('field 2', :name => :age_2, :to_expr => :age_2)
331
- ds = Linkage::Dataset.new("foo:/bar", "baz")
332
- ds.add_filter(field_1, :>, field_2)
333
- @dataset.expects(:filter).with(expr{age > age_2}).returns(@dataset)
334
- @dataset.expects(:each)
335
- ds.each { }
31
+ test "adapter_scheme" do
32
+ ds = Linkage::Dataset.new('foo:/bar', "foo", {:foo => 'bar'})
33
+ @dataset.stubs(:db).returns(@database)
34
+ @database.expects(:adapter_scheme).returns(:foo)
35
+ assert_equal :foo, ds.adapter_scheme
336
36
  end
337
37
  end
@@ -1,12 +1,6 @@
1
1
  require 'helper'
2
2
 
3
3
  class UnitTests::TestField < Test::Unit::TestCase
4
- def new_field(name, schema, ruby_type, dataset = nil)
5
- f = Linkage::Field.new(name, schema, ruby_type)
6
- f.dataset = dataset || stub('dataset')
7
- f
8
- end
9
-
10
4
  test "subclass of data" do
11
5
  assert_equal Linkage::Data, Linkage::Field.superclass
12
6
  end
@@ -0,0 +1,31 @@
1
+ require 'helper'
2
+
3
+ class UnitTests::TestFieldSet < Test::Unit::TestCase
4
+ def setup
5
+ super
6
+ @schema = {
7
+ :id => {:allow_null=>true, :default=>nil, :primary_key=>true, :db_type=>"integer", :type=>:integer, :ruby_default=>nil},
8
+ :first_name => {:allow_null=>true, :default=>nil, :primary_key=>false, :db_type=>"varchar(255)", :type=>:string, :ruby_default=>nil},
9
+ :last_name => {:allow_null=>true, :default=>nil, :primary_key=>false, :db_type=>"varchar(255)", :type=>:string, :ruby_default=>nil}
10
+ }
11
+ end
12
+
13
+ test "subclass of Hash" do
14
+ assert_equal Hash, Linkage::FieldSet.superclass
15
+ end
16
+
17
+ test "creates fields on initialization" do
18
+ field_1 = stub('id field')
19
+ field_2 = stub('first_name field')
20
+ field_3 = stub('last_name field')
21
+ Linkage::Field.expects(:new).with(:id, @schema[:id]).returns(field_1)
22
+ Linkage::Field.expects(:new).with(:first_name, @schema[:first_name]).returns(field_2)
23
+ Linkage::Field.expects(:new).with(:last_name, @schema[:last_name]).returns(field_3)
24
+
25
+ fs = Linkage::FieldSet.new(@schema)
26
+ assert_equal field_1, fs.primary_key
27
+ assert_equal field_1, fs[:id]
28
+ assert_equal field_2, fs[:first_name]
29
+ assert_equal field_3, fs[:last_name]
30
+ end
31
+ end
@@ -55,38 +55,32 @@ class UnitTests::TestFunction < Test::Unit::TestCase
55
55
 
56
56
  test "function with field" do
57
57
  klass = new_function('foo', {:type => String})
58
- dataset = stub('dataset')
59
- field = stub_field('field', :name => :bar, :ruby_type => {:type => String}, :dataset => dataset)
58
+ field = stub_field('field', :name => :bar, :ruby_type => {:type => String})
60
59
  f = klass.new(field)
61
60
  assert_equal :foo_bar, f.name
62
61
  assert_equal :foo.sql_function(:bar), f.to_expr
63
62
  assert !f.static?
64
- assert_equal dataset, f.dataset
65
63
  end
66
64
 
67
65
  test "function with dynamic function" do
68
66
  klass_1 = new_function('foo', {:type => String})
69
67
  klass_2 = new_function('bar', {:type => String})
70
68
 
71
- dataset = stub('dataset')
72
- field = stub_field('field', :name => :baz, :ruby_type => {:type => String}, :dataset => dataset)
69
+ field = stub_field('field', :name => :baz, :ruby_type => {:type => String})
73
70
  func_1 = klass_1.new(field)
74
71
  assert_equal :foo_baz, func_1.name
75
72
  assert !func_1.static?
76
- assert_equal dataset, func_1.dataset
77
73
 
78
74
  func_2 = klass_2.new(func_1)
79
75
  assert_equal :bar_foo_baz, func_2.name
80
76
  assert !func_2.static?
81
77
  assert_equal :bar.sql_function(:foo.sql_function(:baz)), func_2.to_expr
82
- assert_equal dataset, func_2.dataset
83
78
  end
84
79
 
85
80
  test "function with static function" do
86
81
  klass_1 = new_function('foo', {:type => String})
87
82
  klass_2 = new_function('bar', {:type => String})
88
83
 
89
- dataset = stub('dataset')
90
84
  func_1 = klass_1.new(123)
91
85
  assert_equal :foo_123, func_1.name
92
86
  assert func_1.static?
@@ -106,25 +100,21 @@ class UnitTests::TestFunction < Test::Unit::TestCase
106
100
  assert_equal :foo_123, func_1.name
107
101
  assert func_1.static?
108
102
 
109
- dataset = stub('dataset')
110
- field = stub_field('field', :name => :quux, :ruby_type => {:type => String}, :dataset => dataset)
103
+ field = stub_field('field', :name => :quux, :ruby_type => {:type => String})
111
104
  func_2 = klass_2.new(field)
112
105
  assert_equal :bar_quux, func_2.name
113
106
  assert !func_2.static?
114
- assert_equal dataset, func_2.dataset
115
107
 
116
108
  func_3 = klass_3.new(func_2, func_1)
117
109
  assert_equal :baz_bar_quux_foo_123, func_3.name
118
110
  assert !func_3.static?
119
- assert_equal dataset, func_3.dataset
120
111
  assert_equal :baz.sql_function(:bar.sql_function(:quux), :foo.sql_function(123)), func_3.to_expr
121
112
  end
122
113
 
123
114
  test "function with multiple fields" do
124
115
  klass = new_function('foo', {:type => String})
125
- dataset = stub('dataset')
126
- field_1 = stub_field('field', :name => :bar, :ruby_type => {:type => String}, :dataset => dataset)
127
- field_2 = stub_field('field', :name => :baz, :ruby_type => {:type => String}, :dataset => dataset)
116
+ field_1 = stub_field('field', :name => :bar, :ruby_type => {:type => String})
117
+ field_2 = stub_field('field', :name => :baz, :ruby_type => {:type => String})
128
118
  func = klass.new(field_1, field_2)
129
119
  assert_equal :foo_bar_baz, func.name
130
120
  assert_equal :foo.sql_function(:bar, :baz), func.to_expr
@@ -133,24 +123,10 @@ class UnitTests::TestFunction < Test::Unit::TestCase
133
123
 
134
124
  test "function with multiple mixed arguments" do
135
125
  klass = new_function('foo', {:type => String})
136
- dataset = stub('dataset')
137
- field = stub_field('field', :name => :bar, :ruby_type => {:type => String}, :dataset => dataset)
126
+ field = stub_field('field', :name => :bar, :ruby_type => {:type => String})
138
127
  f = klass.new(field, 123, 'abc')
139
128
  assert_equal :foo_bar_123_abc, f.name
140
129
  assert_equal :foo.sql_function(:bar, 123, 'abc'), f.to_expr
141
- assert_equal dataset, f.dataset
142
- end
143
-
144
- test "illegal function with fields from more than one dataset" do
145
- klass = new_function('foo', {:type => String})
146
- dataset_1 = stub('dataset 1')
147
- dataset_2 = stub('dataset 2')
148
- field_1 = stub_field('field', :name => :bar, :ruby_type => {:type => String}, :dataset => dataset_1)
149
- field_2 = stub_field('field', :name => :baz, :ruby_type => {:type => String}, :dataset => dataset_2)
150
-
151
- assert_raises(ArgumentError) do
152
- func = klass.new(field_1, field_2)
153
- end
154
130
  end
155
131
 
156
132
  test "fetching registered function" do
@@ -0,0 +1,18 @@
1
+ require 'helper'
2
+
3
+ class TestResultSet < Test::Unit::TestCase
4
+ def setup
5
+ @config = stub('configuration', {
6
+ :results_uri => 'foo://bar',
7
+ :results_uri_options => {:blah => 'junk'}
8
+ })
9
+ end
10
+
11
+ test "creating a result set with a configuration" do
12
+ result_set = Linkage::ResultSet.new(@config)
13
+ end
14
+
15
+ test "records?" do
16
+ pend
17
+ end
18
+ end
@@ -1,14 +1,29 @@
1
1
  require 'helper'
2
2
 
3
3
  class UnitTests::TestRunner < Test::Unit::TestCase
4
- test "initialization" do
5
- conf = stub("configuration")
6
- runner = Linkage::Runner.new(conf, "foo:/results")
4
+ def setup
5
+ @result_set = stub("result set")
6
+ @config = stub("configuration", :result_set => @result_set)
7
+ end
8
+
9
+ test "initialization creates a result set" do
10
+ runner = Linkage::Runner.new(@config)
11
+ end
12
+
13
+ test "initialization with deprecated uri and options" do
14
+ @config.expects(:save_results_in).with("foo:/results", {:foo => 'bar'})
15
+ Linkage::Runner.any_instance.expects(:warn)
16
+ runner = Linkage::Runner.new(@config, "foo:/results", {:foo => 'bar'})
7
17
  end
8
18
 
9
19
  test "execute raises error" do
10
- conf = stub("configuration")
11
- runner = Linkage::Runner.new(conf, "foo:/results")
20
+ runner = Linkage::Runner.new(@config)
12
21
  assert_raise_kind_of(NotImplementedError) { runner.execute }
13
22
  end
23
+
24
+ test "result_set gets ResultSet from config" do
25
+ runner = Linkage::Runner.new(@config)
26
+ @config.expects(:result_set).returns(@result_set)
27
+ assert_equal @result_set, runner.result_set
28
+ end
14
29
  end