@@ -26,15 +26,22 @@ namespace {
2626
2727namespace btproto = ::google::bigtable::v2;
2828using ::google::cloud::testing_util::FakeCompletionQueueImpl;
29+ using ::google::cloud::testing_util::StatusIs;
2930using ::testing::HasSubstr;
31+ using ::testing::MockFunction;
32+
33+ Options NonEmptyOptions () {
34+ struct TestOption {
35+ using Type = bool ;
36+ };
37+ return Options{}.set <TestOption>(true );
38+ }
3039
3140// / Define types and functions used in the tests.
32- namespace {
3341class TableTest : public ::google::cloud::bigtable::testing::TableTestFixture {
3442 public:
3543 TableTest () : TableTestFixture(CompletionQueue{}) {}
3644};
37- } // anonymous namespace
3845
3946TEST_F (TableTest, ClientProjectId) {
4047 EXPECT_EQ (kProjectId , client_->project_id ());
@@ -260,6 +267,127 @@ TEST_F(ValidContextMdAsyncTest, AsyncReadModifyWriteRow) {
260267 ReadModifyWriteRule::AppendValue (" fam" , " list" , " ;element" )));
261268}
262269
270+ TEST_F (TableTest, ApplyWithOptions) {
271+ Table table (client_, kTableId );
272+ auto status = table.Apply (SingleRowMutation (" row" ), NonEmptyOptions ());
273+ EXPECT_THAT (status, StatusIs (StatusCode::kInvalidArgument ));
274+ }
275+
276+ TEST_F (TableTest, AsyncApplyWithOptions) {
277+ Table table (client_, kTableId );
278+ auto status = table.AsyncApply (SingleRowMutation (" row" ), NonEmptyOptions ());
279+ EXPECT_THAT (status.get (), StatusIs (StatusCode::kInvalidArgument ));
280+ }
281+
282+ TEST_F (TableTest, BulkApplyWithOptions) {
283+ Table table (client_, kTableId );
284+ auto bulk = BulkMutation (SingleRowMutation (" r1" ), SingleRowMutation (" r2" ));
285+ auto failed = table.BulkApply (bulk, NonEmptyOptions ());
286+ ASSERT_EQ (2 , failed.size ());
287+ EXPECT_EQ (0 , failed[0 ].original_index ());
288+ EXPECT_THAT (failed[0 ].status (), StatusIs (StatusCode::kInvalidArgument ));
289+ EXPECT_EQ (1 , failed[1 ].original_index ());
290+ EXPECT_THAT (failed[1 ].status (), StatusIs (StatusCode::kInvalidArgument ));
291+ }
292+
293+ TEST_F (TableTest, AsyncBulkApplyWithOptions) {
294+ Table table (client_, kTableId );
295+ auto bulk = BulkMutation (SingleRowMutation (" r1" ), SingleRowMutation (" r2" ));
296+ auto failed = table.AsyncBulkApply (bulk, NonEmptyOptions ()).get ();
297+ ASSERT_EQ (2 , failed.size ());
298+ EXPECT_EQ (0 , failed[0 ].original_index ());
299+ EXPECT_THAT (failed[0 ].status (), StatusIs (StatusCode::kInvalidArgument ));
300+ EXPECT_EQ (1 , failed[1 ].original_index ());
301+ EXPECT_THAT (failed[1 ].status (), StatusIs (StatusCode::kInvalidArgument ));
302+ }
303+
304+ TEST_F (TableTest, ReadRowsWithOptions) {
305+ Table table (client_, kTableId );
306+ auto reader =
307+ table.ReadRows (RowSet (), Filter::PassAllFilter (), NonEmptyOptions ());
308+ auto it = reader.begin ();
309+ EXPECT_NE (it, reader.end ());
310+ EXPECT_THAT (*it, StatusIs (StatusCode::kInvalidArgument ));
311+ EXPECT_EQ (++it, reader.end ());
312+ }
313+
314+ TEST_F (TableTest, ReadRowsWithLimitWithOptions) {
315+ Table table (client_, kTableId );
316+ auto reader =
317+ table.ReadRows (RowSet (), 1 , Filter::PassAllFilter (), NonEmptyOptions ());
318+ auto it = reader.begin ();
319+ EXPECT_NE (it, reader.end ());
320+ EXPECT_THAT (*it, StatusIs (StatusCode::kInvalidArgument ));
321+ EXPECT_EQ (++it, reader.end ());
322+ }
323+
324+ TEST_F (TableTest, ReadRowWithOptions) {
325+ Table table (client_, kTableId );
326+ auto row = table.ReadRow (" row" , Filter::PassAllFilter (), NonEmptyOptions ());
327+ EXPECT_THAT (row, StatusIs (StatusCode::kInvalidArgument ));
328+ }
329+
330+ TEST_F (TableTest, AsyncReadRowWithOptions) {
331+ Table table (client_, kTableId );
332+ auto row =
333+ table.AsyncReadRow (" row" , Filter::PassAllFilter (), NonEmptyOptions ());
334+ EXPECT_THAT (row.get (), StatusIs (StatusCode::kInvalidArgument ));
335+ }
336+
337+ TEST_F (TableTest, CheckAndMutateRowWithOptions) {
338+ Table table (client_, kTableId );
339+ auto branch = table.CheckAndMutateRow (" row" , Filter::PassAllFilter (), {}, {},
340+ NonEmptyOptions ());
341+ EXPECT_THAT (branch, StatusIs (StatusCode::kInvalidArgument ));
342+ }
343+
344+ TEST_F (TableTest, AsyncCheckAndMutateRowWithOptions) {
345+ Table table (client_, kTableId );
346+ auto branch = table.AsyncCheckAndMutateRow (" row" , Filter::PassAllFilter (), {},
347+ {}, NonEmptyOptions ());
348+ EXPECT_THAT (branch.get (), StatusIs (StatusCode::kInvalidArgument ));
349+ }
350+
351+ TEST_F (TableTest, SampleRowsWithOptions) {
352+ Table table (client_, kTableId );
353+ auto rows = table.SampleRows (NonEmptyOptions ());
354+ EXPECT_THAT (rows, StatusIs (StatusCode::kInvalidArgument ));
355+ }
356+
357+ TEST_F (TableTest, AsyncSampleRowsWithOptions) {
358+ Table table (client_, kTableId );
359+ auto rows = table.AsyncSampleRows (NonEmptyOptions ());
360+ EXPECT_THAT (rows.get (), StatusIs (StatusCode::kInvalidArgument ));
361+ }
362+
363+ TEST_F (TableTest, AsyncReadRowsWithOptions) {
364+ MockFunction<future<bool >(bigtable::Row const &)> on_row;
365+ EXPECT_CALL (on_row, Call).Times (0 );
366+
367+ MockFunction<void (Status)> on_finish;
368+ EXPECT_CALL (on_finish, Call).WillOnce ([](Status const & status) {
369+ EXPECT_THAT (status, StatusIs (StatusCode::kInvalidArgument ));
370+ });
371+
372+ Table table (client_, kTableId );
373+ table.AsyncReadRows (on_row.AsStdFunction (), on_finish.AsStdFunction (),
374+ RowSet (), Filter::PassAllFilter (), NonEmptyOptions ());
375+ }
376+
377+ TEST_F (TableTest, AsyncReadRowsWithLimitWithOptions) {
378+ MockFunction<future<bool >(bigtable::Row const &)> on_row;
379+ EXPECT_CALL (on_row, Call).Times (0 );
380+
381+ MockFunction<void (Status)> on_finish;
382+ EXPECT_CALL (on_finish, Call).WillOnce ([](Status const & status) {
383+ EXPECT_THAT (status, StatusIs (StatusCode::kInvalidArgument ));
384+ });
385+
386+ Table table (client_, kTableId );
387+ table.AsyncReadRows (on_row.AsStdFunction (), on_finish.AsStdFunction (),
388+ RowSet (), 1 , Filter::PassAllFilter (), NonEmptyOptions ());
389+ }
390+
263391} // namespace
264392GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
265393} // namespace bigtable
0 commit comments