Skip to content

Commit

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

Proposals map[string]map[string]*types.Proposal
Votes map[string]map[string]map[string]*types.Vote
Expand Down Expand Up @@ -156,6 +157,10 @@ func (d *StubDatabase) UpsertLastBlockHeight(
}

func (d *StubDatabase) UpsertMute(mute *types.Mute) error {
if d.UpsertMuteError != nil {
return d.UpsertMuteError
}

if d.Mutes == nil {
d.Mutes = []*types.Mute{}
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/reporters/telegram/add_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 @@ -17,7 +19,7 @@ func (reporter *Reporter) HandleAddMute(c tele.Context) error {

if insertErr := reporter.MutesManager.AddMute(mute); insertErr != nil {
reporter.Logger.Error().Err(insertErr).Msg("Error adding mute")
return reporter.BotReply(c, "Error adding mute")
return reporter.BotReply(c, fmt.Sprintf("Error adding mute: %s", insertErr))
}

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

0 comments on commit 9b23c2e

Please sign in to comment.