Debian Codegraph @

link_test.go

raw symbols SCIP
1 package activitypub
2
3 import (
4 "reflect"
5 "testing"
6 )
7
8 func TestLinkNew(t *testing.T) {
9 testValue := ID("test")
10 var testType ActivityVocabularyType
11
12 l := LinkNew(testValue, testType)
13
14 if l.ID != testValue {
15 t.Errorf("APObject Id '%v' different than expected '%v'", l.ID, testValue)
16 }
17 if !l.Match(LinkType) {
18 t.Errorf("APObject Type '%v' different than expected '%v'", l.GetType(), LinkType)
19 }
20 }
21
22 func TestLink_IsLink(t *testing.T) {
23 l := LinkNew("test", LinkType)
24 if !l.IsLink() {
25 t.Errorf("%#v should be a valid link", l.GetType())
26 }
27 m := LinkNew("test", MentionType)
28 if !m.IsLink() {
29 t.Errorf("%#v should be a valid link", m.GetType())
30 }
31 }
32
33 func TestLink_IsObject(t *testing.T) {
34 l := LinkNew("test", LinkType)
35 if l.IsObject() {
36 t.Errorf("%#v should not be a valid object", l.GetType())
37 }
38 m := LinkNew("test", MentionType)
39 if m.IsObject() {
40 t.Errorf("%#v should not be a valid object", m.GetType())
41 }
42 }
43
44 func TestLink_GetID(t *testing.T) {
45 t.Skipf("TODO")
46 }
47
48 func TestLink_GetLink(t *testing.T) {
49 t.Skipf("TODO")
50 }
51
52 func TestLink_GetType(t *testing.T) {
53 t.Skipf("TODO")
54 }
55
56 func TestLink_UnmarshalJSON(t *testing.T) {
57 t.Skipf("TODO")
58 }
59
60 func TestMentionNew(t *testing.T) {
61 t.Skipf("TODO")
62 }
63
64 func TestLink_IsCollection(t *testing.T) {
65 t.Skipf("TODO")
66 }
67
68 func TestLink_GobEncode(t *testing.T) {
69 type fields struct {
70 ID ID
71 Type Typer
72 Name NaturalLanguageValues
73 Rel IRI
74 MediaType MimeType
75 Height uint
76 Width uint
77 Preview Item
78 Href IRI
79 HrefLang LangRef
80 }
81 tests := []struct {
82 name string
83 fields fields
84 want []byte
85 wantErr bool
86 }{
87 {
88 name: "empty",
89 fields: fields{},
90 want: []byte{},
91 wantErr: false,
92 },
93 }
94 for _, tt := range tests {
95 t.Run(tt.name, func(t *testing.T) {
96 l := Link{
97 ID: tt.fields.ID,
98 Type: tt.fields.Type,
99 Name: tt.fields.Name,
100 Rel: tt.fields.Rel,
101 MediaType: tt.fields.MediaType,
102 Height: tt.fields.Height,
103 Width: tt.fields.Width,
104 Preview: tt.fields.Preview,
105 Href: tt.fields.Href,
106 HrefLang: tt.fields.HrefLang,
107 }
108 got, err := l.GobEncode()
109 if (err != nil) != tt.wantErr {
110 t.Errorf("GobEncode() error = %v, wantErr %v", err, tt.wantErr)
111 return
112 }
113 if !reflect.DeepEqual(got, tt.want) {
114 t.Errorf("GobEncode() got = %#v, want %#v", got, tt.want)
115 }
116 })
117 }
118 }
119
120 func TestLink_GobDecode(t *testing.T) {
121 type fields struct {
122 ID ID
123 Type Typer
124 Name NaturalLanguageValues
125 Rel IRI
126 MediaType MimeType
127 Height uint
128 Width uint
129 Preview Item
130 Href IRI
131 HrefLang LangRef
132 }
133 tests := []struct {
134 name string
135 fields fields
136 data []byte
137 wantErr bool
138 }{
139 {
140 name: "empty",
141 fields: fields{},
142 data: []byte{},
143 wantErr: false,
144 },
145 }
146 for _, tt := range tests {
147 t.Run(tt.name, func(t *testing.T) {
148 l := &Link{
149 ID: tt.fields.ID,
150 Type: tt.fields.Type,
151 Name: tt.fields.Name,
152 Rel: tt.fields.Rel,
153 MediaType: tt.fields.MediaType,
154 Height: tt.fields.Height,
155 Width: tt.fields.Width,
156 Preview: tt.fields.Preview,
157 Href: tt.fields.Href,
158 HrefLang: tt.fields.HrefLang,
159 }
160 if err := l.GobDecode(tt.data); (err != nil) != tt.wantErr {
161 t.Errorf("GobDecode() error = %v, wantErr %v", err, tt.wantErr)
162 }
163 })
164 }
165 }