1
0
Fork 0
mirror of https://github.com/matrix-org/gomatrix synced 2025-12-19 04:38:03 +00:00

Add user ID handling methods

This commit is contained in:
Kegan Dougal 2016-12-06 14:24:27 +00:00
parent 665b35975b
commit 8ef8c8187f
2 changed files with 37 additions and 0 deletions

View file

@ -62,3 +62,25 @@ func TestDecodeUserLocalpartErrors(t *testing.T) {
}
}
}
var localparttests = []struct {
Input string
ExpectOutput string
}{
{"@foo:bar", "foo"},
{"@foo:bar:8448", "foo"},
{"@foo.bar:baz.quuz", "foo.bar"},
}
func TestExtractUserLocalpart(t *testing.T) {
for _, u := range localparttests {
out, err := ExtractUserLocalpart(u.Input)
if err != nil {
t.Errorf("TestExtractUserLocalpart(%s) => Error: %s", u.Input, err)
continue
}
if out != u.ExpectOutput {
t.Errorf("TestExtractUserLocalpart(%s) => Got: %s, Want %s", u.Input, out, u.ExpectOutput)
}
}
}