Debian Codegraph @

relationship_test.go

raw symbols SCIP
1 package activitypub
2
3 import (
4 "testing"
5
6 "github.com/google/go-cmp/cmp"
7 )
8
9 func TestRelationship_GetID(t *testing.T) {
10 t.Skipf("TODO")
11 }
12
13 func TestRelationship_GetLink(t *testing.T) {
14 t.Skipf("TODO")
15 }
16
17 func TestRelationship_GetType(t *testing.T) {
18 t.Skipf("TODO")
19 }
20
21 func TestRelationship_IsCollection(t *testing.T) {
22 t.Skipf("TODO")
23 }
24
25 func TestRelationship_IsLink(t *testing.T) {
26 t.Skipf("TODO")
27 }
28
29 func TestRelationship_IsObject(t *testing.T) {
30 t.Skipf("TODO")
31 }
32
33 func TestRelationship_UnmarshalJSON(t *testing.T) {
34 t.Skipf("TODO")
35 }
36
37 func TestRelationship_Clean(t *testing.T) {
38 t.Skipf("TODO")
39 }
40
41 func TestToRelationship(t *testing.T) {
42 tests := []struct {
43 name string
44 it LinkOrIRI
45 want *Relationship
46 wantErr error
47 }{
48 {
49 name: "empty",
50 },
51 {
52 name: "Valid Relationship",
53 it: Relationship{ID: "test", Type: RelationshipType},
54 want: &Relationship{ID: "test", Type: RelationshipType},
55 },
56 {
57 name: "Valid *Relationship",
58 it: &Relationship{ID: "test", Type: RelationshipType},
59 want: &Relationship{ID: "test", Type: RelationshipType},
60 },
61 {
62 name: "IRI",
63 it: IRI("https://example.com"),
64 wantErr: ErrorInvalidType[Relationship](IRI("")),
65 },
66 {
67 name: "IRIs",
68 it: IRIs{IRI("https://example.com")},
69 wantErr: ErrorInvalidType[Relationship](IRIs{}),
70 },
71 {
72 name: "ItemCollection",
73 it: ItemCollection{},
74 wantErr: ErrorInvalidType[Relationship](ItemCollection{}),
75 },
76 {
77 name: "Object",
78 it: &Object{ID: "test", Type: ArticleType},
79 wantErr: ErrorInvalidType[Relationship](&Object{}),
80 },
81 {
82 name: "Activity",
83 it: &Activity{ID: "test", Type: CreateType},
84 wantErr: ErrorInvalidType[Relationship](&Activity{}),
85 },
86 {
87 name: "IntransitiveActivity",
88 it: &IntransitiveActivity{ID: "test", Type: ArriveType},
89 wantErr: ErrorInvalidType[Relationship](&IntransitiveActivity{}),
90 },
91 }
92 for _, tt := range tests {
93 t.Run(tt.name, func(t *testing.T) {
94 got, err := ToRelationship(tt.it)
95 if !cmp.Equal(err, tt.wantErr, EquateWeakErrors) {
96 t.Errorf("ToRelationship() error = %v, wantErr %v", err, tt.wantErr)
97 return
98 }
99 if !cmp.Equal(got, tt.want) {
100 t.Errorf("ToRelationship() got = %s", cmp.Diff(tt.want, got))
101 }
102 if got != nil && !got.Match(RelationshipType) {
103 t.Errorf("ToRelationship() expected to match Relationship type, got = %v", got.GetType())
104 }
105 })
106 }
107 }