Skip to content

Commit

Permalink
fix: delete stream with name
Browse files Browse the repository at this point in the history
Signed-off-by: Enrique Lacal <[email protected]>
  • Loading branch information
EnriqueL8 committed Jan 22, 2024
1 parent ba21054 commit 9fff21d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/eventstreams/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,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 @@ -260,7 +260,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.ID)
Expand Down
21 changes: 21 additions & 0 deletions pkg/eventstreams/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,27 @@ func TestDeleteStreamFailDelete(t *testing.T) {

}

func TestDeleteStreamByName(t *testing.T) {
es := &EventStreamSpec[testESConfig]{
ID: ptrTo(fftypes.NewUUID().String()),
Name: ptrTo("stream1"),
Status: ptrTo(EventStreamStatusStopped),
}
ctx, esm, _, done := newMockESManager(t, func(mp *mockPersistence) {
mp.eventStreams.On("GetByUUIDOrName", mock.Anything, mock.Anything).Return(es, nil).Once()
mp.eventStreams.On("GetMany", mock.Anything, mock.Anything).Return([]*EventStreamSpec[testESConfig]{es}, &ffapi.FilterResult{}, nil).Once()
mp.eventStreams.On("GetMany", mock.Anything, mock.Anything).Return([]*EventStreamSpec[testESConfig]{}, &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.ID).Return(nil).Once()
})
defer done()

err := esm.DeleteStream(ctx, *es.Name)

Check failure on line 479 in pkg/eventstreams/manager_test.go

View workflow job for this annotation

GitHub Actions / build

invalid operation: EventStreamSpec[testESConfig] (EventStreamSpec is not a generic type)
assert.Regexp(t, "pop", err)

}

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

Check failure on line 486 in pkg/eventstreams/manager_test.go

View workflow job for this annotation

GitHub Actions / build

invalid operation: EventStreamSpec[testESConfig] (EventStreamSpec is not a generic type)
Expand Down

0 comments on commit 9fff21d

Please sign in to comment.