aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorBrian Cully <bjc@kublai.com>2012-02-07 18:42:45 -0500
committerBrian Cully <github.20.shmit@spamgourmet.com>2012-02-07 18:42:45 -0500
commit672fb633ebba099929277c79cb4c5b162c69fc0a (patch)
treefc6c62777ab4cdec79c8175929f0986e93905af1 /test
parent00e493d0ed990abeece6ae5dc06cb3d634b65bfe (diff)
downloadmysqlerl-672fb633ebba099929277c79cb4c5b162c69fc0a.tar.gz
mysqlerl-672fb633ebba099929277c79cb4c5b162c69fc0a.zip
Add a bunch of cursor tests.
Diffstat (limited to 'test')
-rw-r--r--test/mysqlerl_SUITE.erl64
1 files changed, 55 insertions, 9 deletions
diff --git a/test/mysqlerl_SUITE.erl b/test/mysqlerl_SUITE.erl
index 359711a..34a70c7 100644
--- a/test/mysqlerl_SUITE.erl
+++ b/test/mysqlerl_SUITE.erl
@@ -149,7 +149,10 @@ groups() ->
{read_queries, [shuffle],
[describe_table, sql_query, param_query, select_count]},
{cursor, [shuffle],
- [select, first, last, next, prev, next_after_last, prev_at_first]},
+ [select, first, last, next, prev,
+ next_after_first, next_after_last, prev_after_first, prev_after_last,
+ next_all, prev_all, next_prev_next, prev_next_prev,
+ select_relative, select_absolute]},
{trans, [sequence],
[commit, rollback]}].
@@ -206,36 +209,79 @@ select(Config) ->
1, 1),
[{"bjc", _}] = Rows.
+select_absolute(_Config) ->
+ {skip, "Not implemented."}.
+
+select_relative(_Config) ->
+ {skip, "Not implemented."}.
+
first(Config) ->
- mysqlerl:sql_query(?config(db_ref, Config), "SELECT * FROM user"),
+ mysqlerl:select_count(?config(db_ref, Config), "SELECT * FROM user"),
{selected, ?COLS, Rows} = mysqlerl:first(?config(db_ref, Config)),
[{"bjc", _}] = Rows.
last(Config) ->
- mysqlerl:sql_query(?config(db_ref, Config), "SELECT * FROM user"),
+ mysqlerl:select_count(?config(db_ref, Config), "SELECT * FROM user"),
{selected, ?COLS, Rows} = mysqlerl:last(?config(db_ref, Config)),
[{"siobain", _}] = Rows.
next(Config) ->
- mysqlerl:sql_query(?config(db_ref, Config), "SELECT * FROM user"),
+ mysqlerl:select_count(?config(db_ref, Config), "SELECT * FROM user"),
{selected, ?COLS, Rows} = mysqlerl:next(?config(db_ref, Config)),
- [{"siobain", _}] = Rows.
+ [{"bjc", _}] = Rows.
+
+next_after_first(Config) ->
+ mysqlerl:select_count(?config(db_ref, Config), "SELECT * FROM user"),
+ mysqlerl:first(?config(db_ref, Config)),
+ {selected, ?COLS, [{"siobain", _}]} = mysqlerl:next(?config(db_ref, Config)).
next_after_last(Config) ->
- mysqlerl:sql_query(?config(db_ref, Config), "SELECT * FROM user"),
+ mysqlerl:select_count(?config(db_ref, Config), "SELECT * FROM user"),
mysqlerl:last(?config(db_ref, Config)),
{selected, ?COLS, []} = mysqlerl:next(?config(db_ref, Config)).
+next_all(Config) ->
+ mysqlerl:select_count(?config(db_ref, Config), "SELECT * FROM user"),
+ {selected, ?COLS, [{"bjc", _}]} = mysqlerl:next(?config(db_ref, Config)),
+ {selected, ?COLS, [{"siobain", _}]} = mysqlerl:next(?config(db_ref, Config)),
+ {selected, ?COLS, []} = mysqlerl:next(?config(db_ref, Config)).
+
prev(Config) ->
- mysqlerl:sql_query(?config(db_ref, Config), "SELECT * FROM user"),
+ mysqlerl:select_count(?config(db_ref, Config), "SELECT * FROM user"),
+ mysqlerl:last(?config(db_ref, Config)),
{selected, ?COLS, Rows} = mysqlerl:prev(?config(db_ref, Config)),
[{"bjc", _}] = Rows.
-prev_at_first(Config) ->
- mysqlerl:sql_query(?config(db_ref, Config), "SELECT * FROM user"),
+prev_all(Config) ->
+ mysqlerl:select_count(?config(db_ref, Config), "SELECT * FROM user"),
+ mysqlerl:last(?config(db_ref, Config)),
+ {selected, ?COLS, [{"bjc", _}]} = mysqlerl:prev(?config(db_ref, Config)),
+ {selected, ?COLS, []} = mysqlerl:prev(?config(db_ref, Config)).
+
+prev_after_first(Config) ->
+ mysqlerl:select_count(?config(db_ref, Config), "SELECT * FROM user"),
mysqlerl:first(?config(db_ref, Config)),
{selected, ?COLS, []} = mysqlerl:prev(?config(db_ref, Config)).
+prev_after_last(Config) ->
+ mysqlerl:select_count(?config(db_ref, Config), "SELECT * FROM user"),
+ mysqlerl:last(?config(db_ref, Config)),
+ {selected, ?COLS, [{"bjc", _}]} = mysqlerl:prev(?config(db_ref, Config)).
+
+next_prev_next(Config) ->
+ mysqlerl:select_count(?config(db_ref, Config), "SELECT * FROM user"),
+ mysqlerl:first(?config(db_ref, Config)),
+ {selected, ?COLS, [{"siobain", _}]} = mysqlerl:next(?config(db_ref, Config)),
+ {selected, ?COLS, [{"bjc", _}]} = mysqlerl:prev(?config(db_ref, Config)),
+ {selected, ?COLS, [{"siobain", _}]} = mysqlerl:next(?config(db_ref, Config)).
+
+prev_next_prev(Config) ->
+ mysqlerl:select_count(?config(db_ref, Config), "SELECT * FROM user"),
+ mysqlerl:last(?config(db_ref, Config)),
+ {selected, ?COLS, [{"bjc", _}]} = mysqlerl:prev(?config(db_ref, Config)),
+ {selected, ?COLS, [{"siobain", _}]} = mysqlerl:next(?config(db_ref, Config)),
+ {selected, ?COLS, [{"bjc", _}]} = mysqlerl:prev(?config(db_ref, Config)).
+
commit(Config) ->
ok = mysqlerl:commit(?config(db_ref, Config), commit),
{skip, "Not implemented"}.