1
0
Fork 0
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:
diamondburned (Forefront) 2020-02-04 08:13:11 -08:00
parent 85b793a1a7
commit 49b69d1b30
2 changed files with 46 additions and 1 deletions

View file

@ -73,7 +73,7 @@ func (m *RoleMention) ID() discord.Snowflake {
}
func (m *RoleMention) Mention() string {
return "<&" + m.ID().String() + ">"
return "<@&" + m.ID().String() + ">"
}
//

View 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)
}
}
}