-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtypes_test.go
48 lines (37 loc) · 1004 Bytes
/
types_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package bitxid
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
var testDid = DID("did:bitxhub:test-method:test-address")
func TestGetRootMethod(t *testing.T) {
method := testDid.GetRootMethod()
assert.Equal(t, "bitxhub", method)
}
func TestGetSubMethod(t *testing.T) {
method := testDid.GetSubMethod()
assert.Equal(t, "test-method", method)
}
func TestGetAddress(t *testing.T) {
addr := testDid.GetAddress()
assert.Equal(t, "test-address", addr)
}
func TestErrJoin(t *testing.T) {
err := errJoin("doc db store", fmt.Errorf("a error"))
assert.NotNil(t, err)
}
func TestIsValidFormat(t *testing.T) {
did := DID("did:bitxid:appchain001:0x123")
res := did.IsValidFormat()
assert.Equal(t, true, res)
did = DID("did:::")
res = did.IsValidFormat()
assert.Equal(t, false, res)
method := DID("did:bitxid:appchain001:.")
res = method.IsValidFormat()
assert.Equal(t, true, res)
method = DID("did:bitxid:")
res = method.IsValidFormat()
assert.Equal(t, false, res)
}