1515#include " google/cloud/internal/debug_string_protobuf.h"
1616#include " google/cloud/testing_util/scoped_log.h"
1717#include " google/cloud/tracing_options.h"
18+ #include < google/iam/v1/policy.pb.h>
1819#include < google/protobuf/duration.pb.h>
1920#include < google/protobuf/text_format.h>
2021#include < google/protobuf/timestamp.pb.h>
21- #include < google/spanner/v1/mutation.pb.h>
2222#include < gmock/gmock.h>
2323
2424namespace google {
@@ -27,113 +27,87 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
2727namespace internal {
2828namespace {
2929
30- google::spanner ::v1::Mutation MakeMutation () {
30+ google::iam ::v1::Policy MakePolicy () {
3131 auto constexpr kText = R"pb(
32- insert {
33- table: "Singers"
34- columns: "SingerId"
35- columns: "FirstName"
36- columns: "LastName"
37- values {
38- values { string_value: "1" }
39- values { string_value: "test-fname-1" }
40- values { string_value: "test-lname-1" }
41- }
42- values {
43- values { string_value: "2" }
44- values { string_value: "test-fname-2" }
45- values { string_value: "test-lname-2" }
32+ bindings {
33+ role: "roles/viewer"
34+ members: "user:user1@example.com"
35+ members: "user:user2@example.com"
36+ }
37+ audit_configs {
38+ audit_log_configs {
39+ exempted_members: "user:user3@example.com"
40+ exempted_members: "user:user4@example.com"
4641 }
4742 }
4843 )pb" ;
49- google::spanner ::v1::Mutation mutation ;
50- EXPECT_TRUE (google::protobuf::TextFormat::ParseFromString (kText , &mutation ));
51- return mutation ;
44+ google::iam ::v1::Policy policy ;
45+ EXPECT_TRUE (google::protobuf::TextFormat::ParseFromString (kText , &policy ));
46+ return policy ;
5247}
5348
5449TEST (LogWrapperHelpers, DefaultOptions) {
5550 TracingOptions tracing_options;
5651 // clang-format off
5752 std::string const text =
58- R"pb( google.spanner.v1.Mutation { )pb"
59- R"pb( insert { )pb"
60- R"pb( table: "Singers" )pb"
61- R"pb( columns: "SingerId" )pb"
62- R"pb( columns: "FirstName" )pb"
63- R"pb( columns: "LastName" )pb"
64- R"pb( values { values { string_value: "1" } )pb"
65- R"pb( values { string_value: "test-fname-1" } )pb"
66- R"pb( values { string_value: "test-lname-1" } } )pb"
67- R"pb( values { values { string_value: "2" } )pb"
68- R"pb( values { string_value: "test-fname-2" } )pb"
69- R"pb( values { string_value: "test-lname-2" } )pb"
70- R"pb( } )pb"
71- R"pb( } )pb"
72- R"pb( })pb" ;
53+ R"pb( google.iam.v1.Policy { )pb"
54+ R"pb( bindings { )pb"
55+ R"pb( role: "roles/viewer" )pb"
56+ R"pb( members: "user:user1@example.com" )pb"
57+ R"pb( members: "user:user2@example.com" )pb"
58+ R"pb( } )pb"
59+ R"pb( audit_configs { )pb"
60+ R"pb( audit_log_configs { )pb"
61+ R"pb( exempted_members: "user:user3@example.com" )pb"
62+ R"pb( exempted_members: "user:user4@example.com" )pb"
63+ R"pb( } )pb"
64+ R"pb( } )pb"
65+ R"pb( })pb" ;
7366 // clang-format on
74- EXPECT_EQ (text, DebugString (MakeMutation (), tracing_options));
67+ EXPECT_EQ (text, DebugString (MakePolicy (), tracing_options));
7568}
7669
7770TEST (LogWrapperHelpers, MultiLine) {
7871 TracingOptions tracing_options;
7972 tracing_options.SetOptions (" single_line_mode=off" );
8073 // clang-format off
81- std::string const text = R"pb( google.spanner.v1.Mutation {
82- insert {
83- table: "Singers"
84- columns: "SingerId"
85- columns: "FirstName"
86- columns: "LastName"
87- values {
88- values {
89- string_value: "1"
90- }
91- values {
92- string_value: "test-fname-1"
93- }
94- values {
95- string_value: "test-lname-1"
96- }
97- }
98- values {
99- values {
100- string_value: "2"
101- }
102- values {
103- string_value: "test-fname-2"
104- }
105- values {
106- string_value: "test-lname-2"
107- }
74+ std::string const text = R"pb( google.iam.v1.Policy {
75+ bindings {
76+ role: "roles/viewer"
77+ members: "user:user1@example.com"
78+ members: "user:user2@example.com"
79+ }
80+ audit_configs {
81+ audit_log_configs {
82+ exempted_members: "user:user3@example.com"
83+ exempted_members: "user:user4@example.com"
10884 }
10985 }
11086})pb" ;
11187 // clang-format on
112- EXPECT_EQ (text, DebugString (MakeMutation (), tracing_options));
88+ EXPECT_EQ (text, DebugString (MakePolicy (), tracing_options));
11389}
11490
11591TEST (LogWrapperHelpers, Truncate) {
11692 TracingOptions tracing_options;
11793 tracing_options.SetOptions (" truncate_string_field_longer_than=8" );
11894 // clang-format off
11995 std::string const text =
120- R"pb( google.spanner.v1.Mutation { )pb"
121- R"pb( insert { )pb"
122- R"pb( table: "Singers" )pb"
123- R"pb( columns: "SingerId" )pb"
124- R"pb( columns: "FirstNam...<truncated>..." )pb"
125- R"pb( columns: "LastName" )pb"
126- R"pb( values { values { string_value: "1" } )pb"
127- R"pb( values { string_value: "test-fna...<truncated>..." } )pb"
128- R"pb( values { string_value: "test-lna...<truncated>..." } } )pb"
129- R"pb( values { values { string_value: "2" } )pb"
130- R"pb( values { string_value: "test-fna...<truncated>..." } )pb"
131- R"pb( values { string_value: "test-lna...<truncated>..." } )pb"
132- R"pb( } )pb"
133- R"pb( } )pb"
134- R"pb( })pb" ;
96+ R"pb( google.iam.v1.Policy { )pb"
97+ R"pb( bindings { )pb"
98+ R"pb( role: "roles/vi...<truncated>..." )pb"
99+ R"pb( members: "user:use...<truncated>..." )pb"
100+ R"pb( members: "user:use...<truncated>..." )pb"
101+ R"pb( } )pb"
102+ R"pb( audit_configs { )pb"
103+ R"pb( audit_log_configs { )pb"
104+ R"pb( exempted_members: "user:use...<truncated>..." )pb"
105+ R"pb( exempted_members: "user:use...<truncated>..." )pb"
106+ R"pb( } )pb"
107+ R"pb( } )pb"
108+ R"pb( })pb" ;
135109 // clang-format on
136- EXPECT_EQ (text, DebugString (MakeMutation (), tracing_options));
110+ EXPECT_EQ (text, DebugString (MakePolicy (), tracing_options));
137111}
138112
139113TEST (LogWrapperHelpers, Duration) {
0 commit comments