mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-11-27 17:23:00 +00:00
Bot: slightly more tests
This commit is contained in:
parent
85b793a1a7
commit
49b69d1b30
|
@ -73,7 +73,7 @@ func (m *RoleMention) ID() discord.Snowflake {
|
|||
}
|
||||
|
||||
func (m *RoleMention) Mention() string {
|
||||
return "<&" + m.ID().String() + ">"
|
||||
return "<@&" + m.ID().String() + ">"
|
||||
}
|
||||
|
||||
//
|
||||
|
|
45
bot/extras/arguments/mention_test.go
Normal file
45
bot/extras/arguments/mention_test.go
Normal file
|
@ -0,0 +1,45 @@
|
|||
package arguments
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/diamondburned/arikawa/discord"
|
||||
)
|
||||
|
||||
func TestMention(t *testing.T) {
|
||||
var (
|
||||
c ChannelMention
|
||||
u UserMention
|
||||
r RoleMention
|
||||
)
|
||||
|
||||
type mention interface {
|
||||
Parse(arg string) error
|
||||
ID() discord.Snowflake
|
||||
Mention() string
|
||||
}
|
||||
|
||||
var tests = []struct {
|
||||
mention
|
||||
str string
|
||||
id discord.Snowflake
|
||||
}{
|
||||
{&c, "<#123123>", 123123},
|
||||
{&r, "<@&23321>", 23321},
|
||||
{&u, "<@123123>", 123123},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
if err := test.Parse(test.str); err != nil {
|
||||
t.Fatal("Expected", test.id, "error:", err)
|
||||
}
|
||||
|
||||
if id := test.ID(); id != test.id {
|
||||
t.Fatal("Expected", test.id, "got", id)
|
||||
}
|
||||
|
||||
if mention := test.Mention(); mention != test.str {
|
||||
t.Fatal("Expected", test.str, "got", mention)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue