mirror of
https://github.com/cadmium-im/zirconium-go.git
synced 2024-11-23 19:02:20 +00:00
40 lines
1.0 KiB
Go
40 lines
1.0 KiB
Go
|
package models
|
||
|
|
||
|
import "testing"
|
||
|
|
||
|
func TestNewEntityIDFromString(t *testing.T) {
|
||
|
str := "@user@cadmium.org"
|
||
|
|
||
|
eid, err := NewEntityIDFromString(str)
|
||
|
if err != nil {
|
||
|
t.Fatal("error must be null")
|
||
|
}
|
||
|
if eid.Attr != "" || eid.Type != UsernameType || eid.ServerPart != "cadmium.org" || eid.LocalPart != "user" {
|
||
|
t.FailNow()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func TestNewEntityIDFromStringWithAttr(t *testing.T) {
|
||
|
str := "%msisdn:18002003040@cadmium.org"
|
||
|
|
||
|
eid, err := NewEntityIDFromString(str)
|
||
|
if err != nil {
|
||
|
t.Fatal("error must be null")
|
||
|
}
|
||
|
if eid.Attr != "msisdn" || eid.Type != ThirdPIDType || eid.ServerPart != "cadmium.org" || eid.LocalPart != "18002003040" {
|
||
|
t.FailNow()
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func TestNewEntityIDFromStringWithEmailAttr(t *testing.T) {
|
||
|
str := "%email:abslimit_netwhood.online@cadmium.org"
|
||
|
|
||
|
eid, err := NewEntityIDFromString(str)
|
||
|
if err != nil {
|
||
|
t.Fatal("error must be null")
|
||
|
}
|
||
|
if eid.Attr != "email" || eid.Type != ThirdPIDType || eid.ServerPart != "cadmium.org" || eid.LocalPart != "abslimit_netwhood.online" {
|
||
|
t.Fatal(eid.String())
|
||
|
}
|
||
|
}
|