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: delete stream with name #121

Merged
merged 2 commits into from
Jan 23, 2024
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
2 changes: 1 addition & 1 deletion pkg/eventstreams/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ func TestE2E_CRUDLifecycle(t *testing.T) {
assert.NoError(t, err)

// Delete the first stream (which is running still)
err = mgr.DeleteStream(ctx, es1.GetID())
err = mgr.DeleteStream(ctx, *es1.Name)
assert.NoError(t, err)

// Check no streams left
Expand Down
2 changes: 1 addition & 1 deletion pkg/eventstreams/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func (esm *esManager[CT, DT]) DeleteStream(ctx context.Context, nameOrID string)
return err
}
// Now we can delete it fully from the DB
if err := esm.persistence.EventStreams().Delete(ctx, nameOrID); err != nil {
if err := esm.persistence.EventStreams().Delete(ctx, es.spec.GetID()); err != nil {
return err
}
esm.removeStream(es.spec.GetID())
Expand Down
22 changes: 22 additions & 0 deletions pkg/eventstreams/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,28 @@ func TestDeleteStreamFailDelete(t *testing.T) {

}

func TestDeleteStreamByName(t *testing.T) {
es := &GenericEventStream{
ResourceBase: dbsql.ResourceBase{ID: fftypes.NewUUID()},
EventStreamSpecFields: EventStreamSpecFields{
Name: ptrTo("stream1"),
Status: ptrTo(EventStreamStatusStopped),
},
}
ctx, esm, _, done := newMockESManager(t, func(mp *mockPersistence) {
mp.eventStreams.On("GetByUUIDOrName", mock.Anything, mock.Anything, dbsql.FailIfNotFound).Return(es, nil).Once()
mp.eventStreams.On("GetMany", mock.Anything, mock.Anything).Return([]*GenericEventStream{es}, &ffapi.FilterResult{}, nil).Once()
mp.eventStreams.On("GetMany", mock.Anything, mock.Anything).Return([]*GenericEventStream{}, &ffapi.FilterResult{}, nil).Once()
mp.eventStreams.On("Update", mock.Anything, mock.Anything, mock.Anything).Return(nil).Once()
// Expect the ID to be passed to delete
mp.eventStreams.On("Delete", mock.Anything, es.GetID()).Return(nil).Once()
})
defer done()

err := esm.DeleteStream(ctx, *es.Name)
assert.NoError(t, err)
}

func TestResetStreamStopFailTimeout(t *testing.T) {
existing := &eventStream[*GenericEventStream, testData]{
activeState: &activeStream[*GenericEventStream, testData]{},
Expand Down