@@ -138,6 +138,58 @@ TEST(ClientTest, ReadSuccess) {
138138 IsOkAndHolds (RowType (" Ann" , 42 ))));
139139}
140140
141+ TEST (ClientTest, ReadWithLockHint) {
142+ auto conn = std::make_shared<MockConnection>();
143+ Client client (conn);
144+
145+ auto constexpr kText = R"pb(
146+ row_type: {
147+ fields: {
148+ name: "Name",
149+ type: { code: INT64 }
150+ }
151+ fields: {
152+ name: "Id",
153+ type: { code: INT64 }
154+ }
155+ }
156+ )pb" ;
157+ google::spanner::v1::ResultSetMetadata metadata;
158+ ASSERT_TRUE (TextFormat::ParseFromString (kText , &metadata));
159+
160+ EXPECT_CALL (*conn, Read)
161+ .WillOnce ([&metadata](Connection::ReadParams const & params) {
162+ EXPECT_THAT (
163+ params.directed_read_option ,
164+ VariantWith<IncludeReplicas>(AllOf (
165+ Property (&IncludeReplicas::replica_selections,
166+ ElementsAre (ReplicaSelection (ReplicaType::kReadOnly ))),
167+ Property (&IncludeReplicas::auto_failover_disabled, true ))));
168+ EXPECT_THAT (params.lock_hint , Eq (LockHint::kLockHintShared ));
169+ auto source = std::make_unique<MockResultSetSource>();
170+ EXPECT_CALL (*source, Metadata ()).WillRepeatedly (Return (metadata));
171+ EXPECT_CALL (*source, NextRow ())
172+ .WillOnce (Return (spanner_mocks::MakeRow (" Steve" , 12 )))
173+ .WillOnce (Return (spanner_mocks::MakeRow (" Ann" , 42 )))
174+ .WillOnce (Return (Row ()));
175+ return RowStream (std::move (source));
176+ });
177+
178+ KeySet keys = KeySet::All ();
179+ auto rows = client.Read (" table" , std::move (keys), {" column1" , " column2" },
180+ Options{}
181+ .set <DirectedReadOption>(IncludeReplicas (
182+ {ReplicaSelection (ReplicaType::kReadOnly )},
183+ /* auto_failover_disabled=*/ true ))
184+ .set <LockHintOption>(LockHint::kLockHintShared ));
185+
186+ using RowType = std::tuple<std::string, std::int64_t >;
187+ auto stream = StreamOf<RowType>(rows);
188+ auto actual = std::vector<StatusOr<RowType>>{stream.begin (), stream.end ()};
189+ EXPECT_THAT (actual, ElementsAre (IsOkAndHolds (RowType (" Steve" , 12 )),
190+ IsOkAndHolds (RowType (" Ann" , 42 ))));
191+ }
192+
141193TEST (ClientTest, ReadFailure) {
142194 auto conn = std::make_shared<MockConnection>();
143195 Client client (conn);
@@ -404,7 +456,8 @@ TEST(ClientTest, CommitMutatorSuccess) {
404456
405457 auto conn = std::make_shared<MockConnection>();
406458 Transaction txn = MakeReadWriteTransaction (); // placeholder
407- Connection::ReadParams actual_read_params{txn, {}, {}, {}, {}, {}, {}, {}};
459+ Connection::ReadParams actual_read_params{txn, {}, {}, {}, {},
460+ {}, {}, {}, {}};
408461 Connection::CommitParams actual_commit_params{txn, {}, {}};
409462
410463 auto source = std::make_unique<MockResultSetSource>();
@@ -453,7 +506,8 @@ TEST(ClientTest, CommitMutatorSuccess) {
453506TEST (ClientTest, CommitMutatorRollback) {
454507 auto conn = std::make_shared<MockConnection>();
455508 Transaction txn = MakeReadWriteTransaction (); // placeholder
456- Connection::ReadParams actual_read_params{txn, {}, {}, {}, {}, {}, {}, {}};
509+ Connection::ReadParams actual_read_params{txn, {}, {}, {}, {},
510+ {}, {}, {}, {}};
457511
458512 auto source = std::make_unique<MockResultSetSource>();
459513 auto constexpr kText = R"pb(
@@ -495,7 +549,8 @@ TEST(ClientTest, CommitMutatorRollback) {
495549TEST (ClientTest, CommitMutatorRollbackError) {
496550 auto conn = std::make_shared<MockConnection>();
497551 Transaction txn = MakeReadWriteTransaction (); // placeholder
498- Connection::ReadParams actual_read_params{txn, {}, {}, {}, {}, {}, {}, {}};
552+ Connection::ReadParams actual_read_params{txn, {}, {}, {}, {},
553+ {}, {}, {}, {}};
499554
500555 auto source = std::make_unique<MockResultSetSource>();
501556 auto constexpr kText = R"pb(
0 commit comments