mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-11-17 20:32:48 +00:00
46 lines
774 B
Go
46 lines
774 B
Go
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)
|
|
}
|
|
}
|
|
}
|