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:
parent
665b35975b
commit
8ef8c8187f
2 changed files with 37 additions and 0 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue