Skip to content

Commit

Permalink
chore: add delete_mute tests
Browse files Browse the repository at this point in the history
  • Loading branch information
freak12techno committed Dec 1, 2024
1 parent 9b23c2e commit e6cac86
Show file tree
Hide file tree
Showing 5 changed files with 455 additions and 3 deletions.
3 changes: 3 additions & 0 deletions assets/responses/delete-mute-no-params.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Deleted mute with the following params:
<strong>Chain:</strong> all chains
<strong>Proposal ID:</strong> all proposals
3 changes: 3 additions & 0 deletions assets/responses/delete-mute-params.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Deleted mute with the following params:
<strong>Chain:</strong> chain
<strong>Proposal ID:</strong> proposal
5 changes: 5 additions & 0 deletions pkg/database/stub.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type StubDatabase struct {
UpsertVoteError error
IsMutedError error
UpsertMuteError error
DeleteMuteError error

Proposals map[string]map[string]*types.Proposal
Votes map[string]map[string]map[string]*types.Vote
Expand Down Expand Up @@ -187,6 +188,10 @@ func (d *StubDatabase) GetAllMutes() ([]*types.Mute, error) {
}

func (d *StubDatabase) DeleteMute(mute *types.Mute) (bool, error) {
if d.DeleteMuteError != nil {
return false, d.DeleteMuteError
}

if d.Mutes == nil {
return false, nil
}
Expand Down
8 changes: 5 additions & 3 deletions pkg/reporters/telegram/delete_mute.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package telegram

import (
"fmt"

tele "gopkg.in/telebot.v3"
)

Expand All @@ -15,10 +17,10 @@ func (reporter *Reporter) HandleDeleteMute(c tele.Context) error {
return c.Reply("Error deleting mute: " + err)
}

if found, deleteErr := reporter.MutesManager.DeleteMute(mute); !found {
if found, deleteErr := reporter.MutesManager.DeleteMute(mute); deleteErr != nil {
return c.Reply(fmt.Sprintf("Error deleting mute: %s!", deleteErr))
} else if !found {
return c.Reply("Could not find the mute to delete!")
} else if deleteErr != nil {
return c.Reply("Error deleting mute!")
}

return reporter.ReplyRender(c, "mute_deleted", mute)
Expand Down
Loading

0 comments on commit e6cac86

Please sign in to comment.