/
test_ext.rb
61 lines (49 loc) · 2.08 KB
/
test_ext.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
require 'helper'
class TestExt < Test::Unit::TestCase
context "The Fusion Tables helper functions" do
setup do
init_config
@ft = GData::Client::FusionTables.new
@ft.clientlogin(username, password)
end
teardown do
@ft.drop(@table.id) if @table and @table.id
end
should "raise ArgumentError if supply unknown types to it" do
assert_raise ArgumentError do
@ft.create_table "test table", [{:name => "test_col", :type => "billys birthday" }]
end
end
should "let you create a table if you get everything right" do
@table = @ft.create_table "test_table", [{:name => "test_col", :type => "string" }]
assert_equal GData::Client::FusionTables::Table, @table.class
end
should "correct your table name to a certain degree on create" do
@table = @ft.create_table "test table", [{:name => "test col", :type => "string" }]
assert_equal "test_table", @table.name
end
should "return you a list of your fusion tables" do
resp = @ft.show_tables
assert_equal GData::Client::FusionTables::Table, resp.first.class if resp.first
end
should "be possible to delete a table with an id" do
table = @ft.create_table "test_table", [{:name => "test col", :type => "string" }]
assert_equal 1, @ft.drop(table.id)
end
should "be possible to delete tables with an array of ids" do
table1 = @ft.create_table "test_table", [{:name => "test col", :type => "string" }]
table2 = @ft.create_table "test_table", [{:name => "test col", :type => "string" }]
assert_equal 2, @ft.drop([table1.id, table2.id])
end
should "be possible to delete multiple tables with a regex" do
table1 = @ft.create_table "test_table", [{:name => "test col", :type => "string" }]
table2 = @ft.create_table "test_table", [{:name => "test col", :type => "string" }]
assert_equal 2, @ft.drop(/^test_/)
end
should "return zero if passed a silly id" do
assert_raise GData::Client::BadRequestError do
assert_equal 0, @ft.drop(235243875629384756)
end
end
end
end