-
Notifications
You must be signed in to change notification settings - Fork 304
feat(bdd): add shared stream operations scenario for Go SDK #3063
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
base: master
Are you sure you want to change the base?
Changes from all commits
9f3d0ab
d9d8908
2e15e71
ac8f36d
5db4ccb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -209,6 +209,47 @@ func (s basicMessagingSteps) thenLastPolledMessageMatchesSent(ctx context.Contex | |
| return nil | ||
| } | ||
|
|
||
| func (s basicMessagingSteps) whenUpdateStreamName(ctx context.Context, newName string) error { | ||
| c := getBasicMessagingCtx(ctx) | ||
| streamIdentifier, _ := iggcon.NewIdentifier(*c.lastStreamID) | ||
| if err := c.client.UpdateStream(streamIdentifier, newName); err != nil { | ||
| return fmt.Errorf("failed to update stream: %w", err) | ||
| } | ||
| c.lastStreamName = &newName | ||
| return nil | ||
| } | ||
|
|
||
| func (s basicMessagingSteps) thenStreamNameUpdated(ctx context.Context, expectedName string) error { | ||
| c := getBasicMessagingCtx(ctx) | ||
| streamIdentifier, _ := iggcon.NewIdentifier(*c.lastStreamID) | ||
| stream, err := c.client.GetStream(streamIdentifier) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to get stream: %w", err) | ||
| } | ||
| if stream.Name != expectedName { | ||
| return fmt.Errorf("expected stream name %s, got %s", expectedName, stream.Name) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (s basicMessagingSteps) whenDeleteStream(ctx context.Context) error { | ||
| c := getBasicMessagingCtx(ctx) | ||
| streamIdentifier, _ := iggcon.NewIdentifier(*c.lastStreamID) | ||
| if err := c.client.DeleteStream(streamIdentifier); err != nil { | ||
| return fmt.Errorf("failed to delete stream: %w", err) | ||
| } | ||
| c.lastStreamID = nil | ||
| return nil | ||
| } | ||
|
|
||
| func (s basicMessagingSteps) thenStreamDeletedSuccessfully(ctx context.Context) error { | ||
| c := getBasicMessagingCtx(ctx) | ||
| if c.lastStreamID != nil { | ||
| return errors.New("stream ID should be nil after deletion") | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (s basicMessagingSteps) givenNoStreams(ctx context.Context) error { | ||
| client := getBasicMessagingCtx(ctx).client | ||
| streams, err := client.GetStreams() | ||
|
|
@@ -322,10 +363,20 @@ func initBasicMessagingScenario(sc *godog.ScenarioContext) { | |
| sc.Step(`the topic should be created successfully`, s.thenTopicCreatedSuccessfully) | ||
| sc.Step(`^the topic should have name "([^"]*)"$`, s.thenTopicHasName) | ||
| sc.Step(`^the topic should have (\d+) partitions$`, s.thenTopicsHasPartitions) | ||
| sc.Step(`^I update the stream name to "([^"]*)"$`, s.whenUpdateStreamName) | ||
| sc.Step(`^the stream name should be updated to "([^"]*)"$`, s.thenStreamNameUpdated) | ||
| sc.Step(`I delete the stream`, s.whenDeleteStream) | ||
| sc.Step(`the stream should be deleted successfully`, s.thenStreamDeletedSuccessfully) | ||
|
Comment on lines
+368
to
+369
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I recommend |
||
| sc.After(func(ctx context.Context, sc *godog.Scenario, scErr error) (context.Context, error) { | ||
| c := getBasicMessagingCtx(ctx) | ||
| if err := c.client.Close(); err != nil { | ||
| scErr = errors.Join(scErr, fmt.Errorf("error closing client: %w", err)) | ||
| if c.client != nil && c.lastStreamID != nil { | ||
| streamIdentifier, _ := iggcon.NewIdentifier(*c.lastStreamID) | ||
| _ = c.client.DeleteStream(streamIdentifier) | ||
| } | ||
| if c.client != nil { | ||
| if err := c.client.Close(); err != nil { | ||
| scErr = errors.Join(scErr, fmt.Errorf("error closing client: %w", err)) | ||
| } | ||
|
Comment on lines
+372
to
+379
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I’m not sure it’s worth cleaning this up. Even if we do want to, this approach isn’t ideal. We should probably provide a script that cleans up all resources instead (e.g., fetch all streams, topics, users, etc., and delete them), which would work across all scenarios and ensure everything is properly cleaned. For example, if CreateStream(A) actually creates a stream B, but DeleteStream(A) only attempts to delete A, then who is responsible for deleting B? |
||
| } | ||
| return ctx, scErr | ||
| }) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,3 +43,9 @@ Feature: Basic Messaging Operations | |
| And the messages should have sequential offsets from 0 to 9 | ||
| And each message should have the expected payload content | ||
| And the last polled message should match the last sent message | ||
|
|
||
| When I update the stream name to "test-stream-updated" | ||
| Then the stream name should be updated to "test-stream-updated" | ||
|
|
||
| When I delete the stream | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think it would be better to have "stream with name" here (or "stream with id") to avoid implicit deduction of stream_name based on previously added/modified streams. |
||
| Then the stream should be deleted successfully | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to call
GetStreamhere to verify whether the stream is actually deleted.