feat(api): add delete speaker functionality and corresponding tests
CI / changes (push) Successful in 8s
CI / commitlint (push) Has been skipped
CI / openapi (push) Successful in 26s
CI / web (push) Successful in 34s
CI / go (push) Failing after 36s
CI / bird2 (push) Has been skipped
CI / release (push) Has been skipped
CI / changes (push) Successful in 8s
CI / commitlint (push) Has been skipped
CI / openapi (push) Successful in 26s
CI / web (push) Successful in 34s
CI / go (push) Failing after 36s
CI / bird2 (push) Has been skipped
CI / release (push) Has been skipped
- Implemented a DELETE endpoint for removing speakers, including necessary authorization checks and response handling. - Added a handler for the delete operation in the HTTP API. - Created unit tests to verify the delete functionality, ensuring proper deletion and response codes. - Updated OpenAPI documentation to reflect the new delete speaker endpoint.
This commit is contained in:
@@ -73,6 +73,7 @@ type Backend interface {
|
||||
GetSpeakerAnyTenant(speakerID string) (*Speaker, error)
|
||||
CreateSpeaker(tenantID string, in *Speaker) (*Speaker, error)
|
||||
UpdateSpeaker(tenantID, id string, patch *SpeakerPatch) (*Speaker, error)
|
||||
DeleteSpeaker(tenantID, id string) error
|
||||
|
||||
GetRevision(tenantID, revisionID string) (*Revision, error)
|
||||
ListRevisions(tenantID, moduleID string, cursor string, limit int) (items []*Revision, nextCursor string, hasMore bool)
|
||||
|
||||
@@ -779,6 +779,18 @@ func (m *Memory) UpdateSpeaker(tenantID, id string, patch *SpeakerPatch) (*Speak
|
||||
return sp, nil
|
||||
}
|
||||
|
||||
func (m *Memory) DeleteSpeaker(tenantID, id string) error {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
sp, ok := m.speakers[id]
|
||||
if !ok || sp.TenantID != tenantID {
|
||||
return ErrNotFound
|
||||
}
|
||||
delete(m.speakers, id)
|
||||
delete(m.publishedRevision, id)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Memory) ListRevisionPrefixes(tenantID, revisionID string, cursor string, limit int) ([]PrefixRow, string, bool) {
|
||||
if limit <= 0 {
|
||||
limit = 50
|
||||
|
||||
Reference in New Issue
Block a user