@@ -20,6 +20,7 @@ import (
2020
2121 "cloud.google.com/go/internal/testutil"
2222 "github.com/google/go-cmp/cmp"
23+ "github.com/google/go-cmp/cmp/cmpopts"
2324 "google.golang.org/api/iterator"
2425 "google.golang.org/api/option"
2526 "google.golang.org/grpc"
@@ -61,17 +62,15 @@ func TestSchemaBasicCreateGetDelete(t *testing.T) {
6162 }
6263 // Don't compare revisionID / create time since that isn't known
6364 // 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 != "" {
6766 t .Errorf ("CreateSchema() -want, +got: %v" , diff )
6867 }
6968
7069 gotConfig , err = admin .Schema (ctx , schemaID , SchemaViewFull )
7170 if err != nil {
7271 t .Errorf ("Schema() got err: %v" , err )
7372 }
74- if diff := testutil .Diff (* gotConfig , schemaConfig ); diff != "" {
73+ if diff := testutil .Diff (* gotConfig , schemaConfig , cmpopts . IgnoreFields ( SchemaConfig {}, "RevisionID" , "RevisionCreateTime" ) ); diff != "" {
7574 t .Errorf ("Schema() -got, +want:\n %v" , diff )
7675 }
7776
@@ -142,11 +141,7 @@ func TestSchema_SchemaRevisions(t *testing.T) {
142141 if err != nil {
143142 t .Fatalf ("CreateSchema() got err: %v" , err )
144143 }
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 != "" {
150145 t .Fatalf ("CreateSchema() -want, +got: %v" , diff )
151146 }
152147
@@ -155,20 +150,16 @@ func TestSchema_SchemaRevisions(t *testing.T) {
155150 if err != nil {
156151 t .Fatalf ("CommitSchema() got err: %v" , err )
157152 }
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 != "" {
161154 t .Fatalf ("CommitSchema() -want, +got: %v" , diff )
162155 }
163156
164157 rbConfig , err := admin .RollbackSchema (ctx , schemaID , gotConfig .RevisionID )
165158 if err != nil {
166159 t .Fatalf ("RollbackSchema() got err: %v" , err )
167160 }
168- schemaConfig .RevisionID = rbConfig .RevisionID
169- schemaConfig .RevisionCreateTime = rbConfig .RevisionCreateTime
170161 schemaConfig .Definition = "def1"
171- if diff := cmp .Diff (* rbConfig , schemaConfig ); diff != "" {
162+ if diff := cmp .Diff (* rbConfig , schemaConfig , cmpopts . IgnoreFields ( SchemaConfig {}, "RevisionID" , "RevisionCreateTime" ) ); diff != "" {
172163 t .Fatalf ("RollbackSchema() -want, +got: %v" , diff )
173164 }
174165
0 commit comments