@@ -20,6 +20,7 @@ import (
20
20
21
21
"cloud.google.com/go/internal/testutil"
22
22
"github.com/google/go-cmp/cmp"
23
+ "github.com/google/go-cmp/cmp/cmpopts"
23
24
"google.golang.org/api/iterator"
24
25
"google.golang.org/api/option"
25
26
"google.golang.org/grpc"
@@ -61,17 +62,15 @@ func TestSchemaBasicCreateGetDelete(t *testing.T) {
61
62
}
62
63
// Don't compare revisionID / create time since that isn't known
63
64
// until after it is created.
64
- schemaConfig .RevisionID = gotConfig .RevisionID
65
- schemaConfig .RevisionCreateTime = gotConfig .RevisionCreateTime
66
- if diff := cmp .Diff (* gotConfig , schemaConfig ); diff != "" {
65
+ if diff := cmp .Diff (* gotConfig , schemaConfig , cmpopts .IgnoreFields (SchemaConfig {}, "RevisionID" , "RevisionCreateTime" )); diff != "" {
67
66
t .Errorf ("CreateSchema() -want, +got: %v" , diff )
68
67
}
69
68
70
69
gotConfig , err = admin .Schema (ctx , schemaID , SchemaViewFull )
71
70
if err != nil {
72
71
t .Errorf ("Schema() got err: %v" , err )
73
72
}
74
- if diff := testutil .Diff (* gotConfig , schemaConfig ); diff != "" {
73
+ if diff := testutil .Diff (* gotConfig , schemaConfig , cmpopts . IgnoreFields ( SchemaConfig {}, "RevisionID" , "RevisionCreateTime" ) ); diff != "" {
75
74
t .Errorf ("Schema() -got, +want:\n %v" , diff )
76
75
}
77
76
@@ -142,11 +141,7 @@ func TestSchema_SchemaRevisions(t *testing.T) {
142
141
if err != nil {
143
142
t .Fatalf ("CreateSchema() got err: %v" , err )
144
143
}
145
- // Update the original config with populated revision ID/create time from server.
146
- // Testing this isn't important since the values aren't known beforehand.
147
- schemaConfig .RevisionID = gotConfig .RevisionID
148
- schemaConfig .RevisionCreateTime = gotConfig .RevisionCreateTime
149
- if diff := cmp .Diff (* gotConfig , schemaConfig ); diff != "" {
144
+ if diff := cmp .Diff (* gotConfig , schemaConfig , cmpopts .IgnoreFields (SchemaConfig {}, "RevisionID" , "RevisionCreateTime" )); diff != "" {
150
145
t .Fatalf ("CreateSchema() -want, +got: %v" , diff )
151
146
}
152
147
@@ -155,20 +150,16 @@ func TestSchema_SchemaRevisions(t *testing.T) {
155
150
if err != nil {
156
151
t .Fatalf ("CommitSchema() got err: %v" , err )
157
152
}
158
- schemaConfig .RevisionID = revConfig .RevisionID
159
- schemaConfig .RevisionCreateTime = revConfig .RevisionCreateTime
160
- if diff := cmp .Diff (* revConfig , schemaConfig ); diff != "" {
153
+ if diff := cmp .Diff (* revConfig , schemaConfig , cmpopts .IgnoreFields (SchemaConfig {}, "RevisionID" , "RevisionCreateTime" )); diff != "" {
161
154
t .Fatalf ("CommitSchema() -want, +got: %v" , diff )
162
155
}
163
156
164
157
rbConfig , err := admin .RollbackSchema (ctx , schemaID , gotConfig .RevisionID )
165
158
if err != nil {
166
159
t .Fatalf ("RollbackSchema() got err: %v" , err )
167
160
}
168
- schemaConfig .RevisionID = rbConfig .RevisionID
169
- schemaConfig .RevisionCreateTime = rbConfig .RevisionCreateTime
170
161
schemaConfig .Definition = "def1"
171
- if diff := cmp .Diff (* rbConfig , schemaConfig ); diff != "" {
162
+ if diff := cmp .Diff (* rbConfig , schemaConfig , cmpopts . IgnoreFields ( SchemaConfig {}, "RevisionID" , "RevisionCreateTime" ) ); diff != "" {
172
163
t .Fatalf ("RollbackSchema() -want, +got: %v" , diff )
173
164
}
174
165
0 commit comments