Skip to content

Commit

Permalink
chore: test events (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
freak12techno authored May 13, 2024
1 parent 835d287 commit 8c650dd
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 1 deletion.
76 changes: 76 additions & 0 deletions pkg/events/events_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package events

import (
"main/pkg/types"
"testing"

"github.com/stretchr/testify/assert"
)

func TestFinishedVotingEvent(t *testing.T) {
t.Parallel()

event := FinishedVotingEvent{}
assert.Equal(t, "finished_voting", event.Name())
assert.False(t, event.IsAlert())
}

func TestProposalsQueryErrorEvent(t *testing.T) {
t.Parallel()

event := ProposalsQueryErrorEvent{}
assert.Equal(t, "proposals_query_error", event.Name())
assert.False(t, event.IsAlert())
}

func TestVoteQueryErrorEvent(t *testing.T) {
t.Parallel()

event := VoteQueryError{}
assert.Equal(t, "vote_query_error", event.Name())
assert.False(t, event.IsAlert())
}

func TestNotVotedEvent(t *testing.T) {
t.Parallel()

event := NotVotedEvent{
Chain: &types.Chain{Name: "chain"},
Proposal: types.Proposal{ID: "proposal"},
Wallet: &types.Wallet{Address: "wallet"},
}
assert.Equal(t, "not_voted", event.Name())
assert.True(t, event.IsAlert())
assert.Equal(t, "chain", event.GetChain().Name)
assert.Equal(t, "proposal", event.GetProposal().ID)
assert.Equal(t, "wallet", event.GetWallet().Address)
}
func TestVotedEvent(t *testing.T) {
t.Parallel()

event := VotedEvent{
Chain: &types.Chain{Name: "chain"},
Proposal: types.Proposal{ID: "proposal"},
Wallet: &types.Wallet{Address: "wallet"},
}
assert.Equal(t, "voted", event.Name())
assert.True(t, event.IsAlert())
assert.Equal(t, "chain", event.GetChain().Name)
assert.Equal(t, "proposal", event.GetProposal().ID)
assert.Equal(t, "wallet", event.GetWallet().Address)
}

func TestRevotedEvent(t *testing.T) {
t.Parallel()

event := RevotedEvent{
Chain: &types.Chain{Name: "chain"},
Proposal: types.Proposal{ID: "proposal"},
Wallet: &types.Wallet{Address: "wallet"},
}
assert.Equal(t, "revoted", event.Name())
assert.True(t, event.IsAlert())
assert.Equal(t, "chain", event.GetChain().Name)
assert.Equal(t, "proposal", event.GetProposal().ID)
assert.Equal(t, "wallet", event.GetWallet().Address)
}
2 changes: 1 addition & 1 deletion pkg/events/vote_query_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ func (e VoteQueryError) Name() string {
}

func (e VoteQueryError) IsAlert() bool {
return true
return false
}

0 comments on commit 8c650dd

Please sign in to comment.