Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pubsub): dont compare revision fields in schema config test #7317

Merged
merged 2 commits into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pubsub/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1806,15 +1806,15 @@ func TestIntegration_SchemaAdmin(t *testing.T) {
Type: tc.schemaType,
Definition: schema,
}
if diff := testutil.Diff(got, want); diff != "" {
if diff := testutil.Diff(got, want, cmpopts.IgnoreFields(SchemaConfig{}, "RevisionID", "RevisionCreateTime")); diff != "" {
t.Fatalf("\ngot: - want: +\n%s", diff)
}

got, err = c.Schema(ctx, schemaID, SchemaViewFull)
if err != nil {
t.Fatalf("SchemaClient.Schema error: %v", err)
}
if diff := testutil.Diff(got, want); diff != "" {
if diff := testutil.Diff(got, want, cmpopts.IgnoreFields(SchemaConfig{}, "RevisionID", "RevisionCreateTime")); diff != "" {
t.Fatalf("\ngot: - want: +\n%s", diff)
}

Expand Down
21 changes: 6 additions & 15 deletions pubsub/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

"cloud.google.com/go/internal/testutil"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"google.golang.org/api/iterator"
"google.golang.org/api/option"
"google.golang.org/grpc"
Expand Down Expand Up @@ -61,17 +62,15 @@ func TestSchemaBasicCreateGetDelete(t *testing.T) {
}
// Don't compare revisionID / create time since that isn't known
// until after it is created.
schemaConfig.RevisionID = gotConfig.RevisionID
schemaConfig.RevisionCreateTime = gotConfig.RevisionCreateTime
if diff := cmp.Diff(*gotConfig, schemaConfig); diff != "" {
if diff := cmp.Diff(*gotConfig, schemaConfig, cmpopts.IgnoreFields(SchemaConfig{}, "RevisionID", "RevisionCreateTime")); diff != "" {
t.Errorf("CreateSchema() -want, +got: %v", diff)
}

gotConfig, err = admin.Schema(ctx, schemaID, SchemaViewFull)
if err != nil {
t.Errorf("Schema() got err: %v", err)
}
if diff := testutil.Diff(*gotConfig, schemaConfig); diff != "" {
if diff := testutil.Diff(*gotConfig, schemaConfig, cmpopts.IgnoreFields(SchemaConfig{}, "RevisionID", "RevisionCreateTime")); diff != "" {
t.Errorf("Schema() -got, +want:\n%v", diff)
}

Expand Down Expand Up @@ -142,11 +141,7 @@ func TestSchema_SchemaRevisions(t *testing.T) {
if err != nil {
t.Fatalf("CreateSchema() got err: %v", err)
}
// Update the original config with populated revision ID/create time from server.
// Testing this isn't important since the values aren't known beforehand.
schemaConfig.RevisionID = gotConfig.RevisionID
schemaConfig.RevisionCreateTime = gotConfig.RevisionCreateTime
if diff := cmp.Diff(*gotConfig, schemaConfig); diff != "" {
if diff := cmp.Diff(*gotConfig, schemaConfig, cmpopts.IgnoreFields(SchemaConfig{}, "RevisionID", "RevisionCreateTime")); diff != "" {
t.Fatalf("CreateSchema() -want, +got: %v", diff)
}

Expand All @@ -155,20 +150,16 @@ func TestSchema_SchemaRevisions(t *testing.T) {
if err != nil {
t.Fatalf("CommitSchema() got err: %v", err)
}
schemaConfig.RevisionID = revConfig.RevisionID
schemaConfig.RevisionCreateTime = revConfig.RevisionCreateTime
if diff := cmp.Diff(*revConfig, schemaConfig); diff != "" {
if diff := cmp.Diff(*revConfig, schemaConfig, cmpopts.IgnoreFields(SchemaConfig{}, "RevisionID", "RevisionCreateTime")); diff != "" {
t.Fatalf("CommitSchema() -want, +got: %v", diff)
}

rbConfig, err := admin.RollbackSchema(ctx, schemaID, gotConfig.RevisionID)
if err != nil {
t.Fatalf("RollbackSchema() got err: %v", err)
}
schemaConfig.RevisionID = rbConfig.RevisionID
schemaConfig.RevisionCreateTime = rbConfig.RevisionCreateTime
schemaConfig.Definition = "def1"
if diff := cmp.Diff(*rbConfig, schemaConfig); diff != "" {
if diff := cmp.Diff(*rbConfig, schemaConfig, cmpopts.IgnoreFields(SchemaConfig{}, "RevisionID", "RevisionCreateTime")); diff != "" {
t.Fatalf("RollbackSchema() -want, +got: %v", diff)
}

Expand Down
1 change: 0 additions & 1 deletion pubsub/topic.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,6 @@ func (t *Topic) Publish(ctx context.Context, msg *Message) *PublishResult {
}
err = t.scheduler.Add(msg.OrderingKey, &bundledMessage{msg, r, msgSize}, msgSize)
if err != nil {
fmt.Printf("got err: %v\n", err)
t.scheduler.Pause(msg.OrderingKey)
ipubsub.SetPublishResult(r, "", err)
}
Expand Down