riak_test/tests/ts_simple_put_invalid_data.erl

62 lines
2.0 KiB
Erlang
Raw Normal View History

%% -------------------------------------------------------------------
%%
%% Copyright (c) 2015 Basho Technologies, Inc.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
%% except in compliance with the License. You may obtain
%% a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing,
%% software distributed under the License is distributed on an
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
%% KIND, either express or implied. See the License for the
%% specific language governing permissions and limitations
%% under the License.
%%
%% -------------------------------------------------------------------
-module(ts_simple_put_invalid_data).
2015-09-22 11:39:37 +00:00
%%
%% this test tries to write well structured data that doesn't
%% meet the criteria defined in the DDL into a bucket
2015-09-22 11:39:37 +00:00
%%
-behavior(riak_test).
-export([confirm/0]).
2015-09-22 11:39:37 +00:00
-include_lib("eunit/include/eunit.hrl").
2015-09-22 11:39:37 +00:00
confirm() ->
DDL = ts_util:get_ddl(),
ValidObj = ts_util:get_valid_obj(),
InvalidObj = ts_util:get_invalid_obj(),
ShortObj = ts_util:get_short_obj(),
LongObj = ts_util:get_long_obj(),
Bucket = ts_util:get_default_bucket(),
{_Cluster, Conn} = ClusterConn = ts_util:cluster_and_connect(single),
Expected1 = {error, {1003, <<"Invalid data found at row index(es) 1">>}},
Expected2 = {error, {1003, <<"Invalid data found at row index(es) 2">>}},
Got = ts_util:ts_put(ClusterConn, normal, DDL, [InvalidObj]),
?assertEqual(Expected1, Got),
2015-11-06 23:27:42 +00:00
Got2 = riakc_ts:put(Conn, Bucket, [ShortObj]),
?assertEqual(Expected1, Got2),
Got3 = riakc_ts:put(Conn, Bucket, [LongObj]),
?assertEqual(Expected1, Got3),
Got4 = riakc_ts:put(Conn, Bucket, [ValidObj, InvalidObj]),
?assertEqual(Expected2, Got4),
Got5 = riakc_ts:put(Conn, Bucket, [ValidObj, ShortObj]),
?assertEqual(Expected2, Got5),
Got6 = riakc_ts:put(Conn, Bucket, [ValidObj, LongObj]),
?assertEqual(Expected2, Got6),
pass.