-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathwidecolumn_read_test.exs
74 lines (63 loc) · 2.08 KB
/
widecolumn_read_test.exs
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
62
63
64
65
66
67
68
69
70
71
72
73
74
defmodule ExAliyunOtsTest.WideColumnRead do
use ExUnit.Case
use ExAliyunOts,
instance: EDCEXTestInstance
require Logger
alias ExAliyunOts.Const.PKType
require PKType
test "wide column read" do
cur_timestamp = System.os_time(:second)
table_name = "test_wcr_#{cur_timestamp}"
create_table_result = create_table(table_name, [{"key", PKType.string()}])
assert create_table_result == :ok
{:ok, _putrow_response} =
put_row(
table_name,
[{"key", "1"}],
[
{"bcol", "bc"},
{"ecol", "ec"},
{"dcol", "dc"},
{"acol", "ac"},
{"fcol", "fc"},
{"ccol", "cc"},
{"room_a", "room_a1"},
{"room_c", "room_c2"},
{"room_b", "room_b3"},
{"room_x", "room_x4"},
{"room_g", "room_g5"},
{"room_e", "room_e6"}
],
condition: condition(:expect_not_exist)
)
# wide column read by start/end
# using `start_column` as "room", `end_column` as "room|" will get all "room_*" attribute columns
{:ok, response} =
get_row(table_name, [{"key", "1"}],
start_column: "room",
end_column: "room|"
)
{_key, attrs} = response.row
assert length(attrs) == 6
assert {"room_a", "room_a1", _} = Enum.at(attrs, 0)
assert {"room_b", "room_b3", _} = Enum.at(attrs, 1)
assert {"room_c", "room_c2", _} = Enum.at(attrs, 2)
assert {"room_e", "room_e6", _} = Enum.at(attrs, 3)
assert {"room_g", "room_g5", _} = Enum.at(attrs, 4)
assert {"room_x", "room_x4", _} = Enum.at(attrs, 5)
# wide column read by filter
{:ok, response} =
get_row(table_name, [{"key", "1"}],
start_column: "room",
filter: pagination(offset: 0, limit: 3)
)
{_key, attrs} = response.row
assert length(attrs) == 3
assert {"room_a", "room_a1", _} = Enum.at(attrs, 0)
assert {"room_b", "room_b3", _} = Enum.at(attrs, 1)
assert {"room_c", "room_c2", _} = Enum.at(attrs, 2)
# delete table
del_result = delete_table(table_name)
assert del_result == :ok
end
end