diff --git a/pkg/eventstreams/e2e_test.go b/pkg/eventstreams/e2e_test.go index b47826f..40fa0d1 100644 --- a/pkg/eventstreams/e2e_test.go +++ b/pkg/eventstreams/e2e_test.go @@ -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 diff --git a/pkg/eventstreams/manager.go b/pkg/eventstreams/manager.go index 71dc19f..350a33c 100644 --- a/pkg/eventstreams/manager.go +++ b/pkg/eventstreams/manager.go @@ -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()) diff --git a/pkg/eventstreams/manager_test.go b/pkg/eventstreams/manager_test.go index b0cfc47..929d4a1 100644 --- a/pkg/eventstreams/manager_test.go +++ b/pkg/eventstreams/manager_test.go @@ -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]{},