Skip to content

Commit

Permalink
feat: add testcases for getDiscordIDs
Browse files Browse the repository at this point in the history
  • Loading branch information
jlehtimaki committed Nov 14, 2023
1 parent 99ebe64 commit 9f5fabb
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions pkg/collector/collector_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package collector

import (
"testing"

"github.com/stretchr/testify/assert"

"github.com/archway-network/relayer_exporter/pkg/config"
)

func TestDiscordIDs(t *testing.T) {
testCases := []struct {
name string
ops []config.Operator
expected string
}{
{
name: "All Valid IDs",
ops: []config.Operator{
{
Discord: config.Discord{ID: "123456"},
},
{
Discord: config.Discord{ID: "12312387"},
},
},
expected: "123456,12312387",
},
{
name: "Some Invalid IDs",
ops: []config.Operator{
{
Discord: config.Discord{ID: "123456"},
},
{
Discord: config.Discord{ID: "ABCDEF"},
},
{
Discord: config.Discord{ID: "789012"},
},
},
expected: "123456,789012",
},
{
name: "No Valid IDs",
ops: []config.Operator{
{Discord: config.Discord{ID: "ABCDEF"}},
{Discord: config.Discord{ID: "GHIJKL"}},
},
expected: "",
},
{
name: "Empty Input",
ops: []config.Operator{{}, {}, {}},
expected: "",
},
}
for _, tc := range testCases {
res := getDiscordIDs(tc.ops)
assert.Equal(t, tc.expected, res)
}
}

0 comments on commit 9f5fabb

Please sign in to comment.