35 lines
991 B
Go
35 lines
991 B
Go
package scopes_test
|
|
|
|
import (
|
|
"fmt"
|
|
tbase "testing"
|
|
|
|
"git.sr.ht/~cco/go-scopes/lib"
|
|
"git.sr.ht/~cco/go-scopes/lib/message"
|
|
"git.sr.ht/~cco/go-scopes/testing"
|
|
)
|
|
|
|
func TestUnit(tb *tbase.T) {
|
|
t := testing.SetUp(tb)
|
|
t.Run("address", AddressTest)
|
|
}
|
|
|
|
func AddressTest(t *testing.T) {
|
|
var ad1 lib.Address = message.SimpleAddress("worker")
|
|
t.AssertEqual(fmt.Sprint(ad1), "#worker//")
|
|
astr := "https://scopes.cy7.eu#server/1abc/2cde"
|
|
var ad2 lib.Address = message.ParseAddress(astr)
|
|
t.AssertEqual(fmt.Sprint(ad2), astr)
|
|
t.AssertEqual(fmt.Sprint(message.ParseAddress("worker")), "#worker//")
|
|
t.AssertEqual(ad1.Url(), "")
|
|
t.AssertEqual(ad2.Url(), "https://scopes.cy7.eu")
|
|
sid, iid := ad1.Interaction()
|
|
t.AssertEqual(sid, "")
|
|
t.AssertEqual(iid, "")
|
|
sid, iid = ad2.Interaction()
|
|
t.AssertEqual(sid, "1abc")
|
|
t.AssertEqual(iid, "2cde")
|
|
ad1.SetUrl("https://scopes.cy7.eu")
|
|
ad1.SetInteraction("1abc", "2cde")
|
|
t.AssertEqual(fmt.Sprint(ad1), "https://scopes.cy7.eu#worker/1abc/2cde")
|
|
}
|