Changes
22 changed files (+88/-88)
-
-
@@ -785,7 +785,7 @@ func (a Activity) GobEncode() ([]byte, error) {func (a *Activity) GobDecode([]byte) error { return errors.New(fmt.Sprintf("GobDecode is not implemented for %T", *a)) } */ */ // Equals verifies if our receiver Object is equals with the "with" Object func (a Activity) Equals(with Item) bool {
-
-
-
@@ -245,7 +245,7 @@ func (a Actor) GobEncode() ([]byte, error) {func (a *Actor) GobDecode([]byte) error { return errors.New(fmt.Sprintf("GobDecode is not implemented for %T", *a)) } */ */ type ( // Application describes a software application.
-
-
-
@@ -376,8 +376,8 @@ func TestPublicKey_MarshalJSON(t *testing.T) {} func assertPersonWithTesting(fn canErrorFunc, expected Item) WithActorFn { return func (p *Person) error { if !assertDeepEquals(fn, p , expected) { return func(p *Person) error { if !assertDeepEquals(fn, p, expected) { return fmt.Errorf("not equal") } return nil
-
-
-
@@ -288,7 +288,7 @@ func (c Collection) GobEncode() ([]byte, error) {func (c *Collection) GobDecode([]byte) error { return errors.New(fmt.Sprintf("GobDecode is not implemented for %T", *c)) } */ */ // ToCollection func ToCollection(it Item) (*Collection, error) {
-
-
-
@@ -252,7 +252,7 @@ func (c CollectionPage) GobEncode() ([]byte, error) {func (c *CollectionPage) GobDecode([]byte) error { return errors.New(fmt.Sprintf("GobDecode is not implemented for %T", *c)) } */ */ // CollectionNew initializes a new CollectionPage func CollectionPageNew(parent CollectionInterface) *CollectionPage {
-
-
-
@@ -145,23 +145,23 @@ func TestToCollectionPage(t *testing.T) {wantErr error }{ "CollectionPage": { it: new(CollectionPage), want: new(CollectionPage), it: new(CollectionPage), want: new(CollectionPage), wantErr: nil, }, "OrderedCollectionPage": { it: new(OrderedCollectionPage), want: new(CollectionPage), it: new(OrderedCollectionPage), want: new(CollectionPage), wantErr: err, }, "OrderedCollection": { it: new(OrderedCollection), want: new(CollectionPage), it: new(OrderedCollection), want: new(CollectionPage), wantErr: err, }, "Collection": { it: new(Collection), want: new(CollectionPage), it: new(Collection), want: new(CollectionPage), wantErr: err, }, }
-
-
-
@@ -195,23 +195,23 @@ func TestToCollection(t *testing.T) {wantErr error }{ "Collection": { it: new(Collection), want: new(Collection), it: new(Collection), want: new(Collection), wantErr: nil, }, "CollectionPage": { it: new(CollectionPage), want: new(Collection), it: new(CollectionPage), want: new(Collection), wantErr: nil, }, "OrderedCollectionPage": { it: new(OrderedCollectionPage), want: new(Collection), it: new(OrderedCollectionPage), want: new(Collection), wantErr: err, }, "OrderedCollection": { it: new(OrderedCollection), want: new(Collection), it: new(OrderedCollection), want: new(Collection), wantErr: err, }, }
-
-
-
@@ -136,9 +136,12 @@ func deepValueEqual(t canErrorFunc, v1, v2 reflect.Value, visited map[visit]boolcase reflect.Struct: for i, n := 0, v1.NumField(); i < n; i++ { var ( f1 = v1.Field(i); f2 = v2.Field(i) n1 = v1.Type().Field(i).Name; n2 = v2.Type().Field(i).Name t1 = f1.Type().Name(); t2 = f2.Type().Name() f1 = v1.Field(i) f2 = v2.Field(i) n1 = v1.Type().Field(i).Name n2 = v2.Type().Field(i).Name t1 = f1.Type().Name() t2 = f2.Type().Name() ) if !deepValueEqual(t, v1.Field(i), v2.Field(i), visited, depth+1) { t("Struct fields at pos %d %s[%s] and %s[%s] are not deeply equal", i, n1, t1, n2, t2)
-
@@ -318,7 +321,7 @@ func TestUnmarshalJSON(t *testing.T) {name string data []byte want Item err error err error }{ { name: "empty",
-
@@ -335,11 +338,11 @@ func TestUnmarshalJSON(t *testing.T) {{ name: "IRIs", data: []byte(fmt.Sprintf("[%q, %q]", "http://example.com", "http://example.net")), want: ItemCollection{ want: ItemCollection{ IRI("http://example.com"), IRI("http://example.net"), }, err: nil, err: nil, }, { name: "object",
-
@@ -357,10 +360,10 @@ func TestUnmarshalJSON(t *testing.T) {name: "collection-2-items", data: []byte(`{ "@context": "https://www.w3.org/ns/activitystreams", "id": "https://federated.git/inbox", "type": "OrderedCollection", "updated": "2021-08-08T16:09:05Z", "first": "https://federated.git/inbox?maxItems=100", "totalItems": 2, "orderedItems": [ { "id": "https://federated.git/activities/07440c39-64b2-4492-89cf-f5c2872cf4ff", "type": "Create", "attributedTo": "https://federated.git/actors/b1757243-080a-49dc-b832-42905d554b91", "to": [ "https://www.w3.org/ns/activitystreams#Public" ], "cc": [ "https://federated.git/actors/b1757243-080a-49dc-b832-42905d554b91/followers" ], "published": "2021-08-08T16:09:05Z", "actor": "https://federated.git/actors/b1757243-080a-49dc-b832-42905d554b91", "object": "https://federated.git/objects/3eb69f77-3b08-4bf1-8760-c7333e2900c4" }, { "id": "https://federated.git/activities/ab9a5511-cdb5-4585-8a48-775d1bf20121", "type": "Like", "attributedTo": "https://federated.git/actors/b1757243-080a-49dc-b832-42905d554b91", "to": [ "https://www.w3.org/ns/activitystreams#Public", "https://federated.git/actors/b1757243-080a-49dc-b832-42905d554b91" ], "published": "2021-08-08T16:09:05Z", "actor": "https://federated.git/actors/b1757243-080a-49dc-b832-42905d554b91", "object": "https://federated.git/objects/3eb69f77-3b08-4bf1-8760-c7333e2900c4" }]}`), want: &OrderedCollection{ ID: "https://federated.git/inbox", Type: OrderedCollectionType, ID: "https://federated.git/inbox", Type: OrderedCollectionType, Updated: time.Date(2021, 8, 8, 16, 9, 5, 0, time.UTC), First: IRI("https://federated.git/inbox?maxItems=100"), First: IRI("https://federated.git/inbox?maxItems=100"), OrderedItems: ItemCollection{ &Activity{ ID: "https://federated.git/activities/07440c39-64b2-4492-89cf-f5c2872cf4ff",
-
@@ -384,7 +387,7 @@ func TestUnmarshalJSON(t *testing.T) {}, TotalItems: 2, }, err: nil, err: nil, }, } for _, tt := range tests {
-
-
-
@@ -14,11 +14,11 @@ type typeId int32type gobEncoder struct { sent map[reflect.Type]typeId // which types we've already sent w *bytes.Buffer enc *gob.Encoder w *bytes.Buffer enc *gob.Encoder } func (e *gobEncoder) encode (it Item) ([]byte, error) { func (e *gobEncoder) encode(it Item) ([]byte, error) { err := e.enc.Encode(it) if err != nil { return nil, err
-
@@ -26,7 +26,6 @@ func (e *gobEncoder) encode (it Item) ([]byte, error) {return e.w.Bytes(), nil } //// GobEncode //func GobEncode(it Item) ([]byte, error) { // w := bytes.NewBuffer(make([]byte, 0))
-
@@ -45,24 +44,24 @@ func (e *gobEncoder) writeIRIProp(i IRI) error {return e.enc.Encode(i.String()) } func (e *gobEncoder) writeGobProp (p string, b []byte) bool { func (e *gobEncoder) writeGobProp(p string, b []byte) bool { c, _ := e.w.Write([]byte(p)) d, _ := e.w.Write(b) return c+d > 0 } func (e *gobEncoder)writeItemGobProp (p string, it Item) bool { func (e *gobEncoder) writeItemGobProp(p string, it Item) bool { return true } func (e *gobEncoder)writeNaturalLanguageGobProp (p string, v NaturalLanguageValues) bool { func (e *gobEncoder) writeNaturalLanguageGobProp(p string, v NaturalLanguageValues) bool { return true } func (e *gobEncoder)writeIRIGobProp (p string, i LinkOrIRI) bool { func (e *gobEncoder) writeIRIGobProp(p string, i LinkOrIRI) bool { return true } func (e *gobEncoder)writeTimeGobProp (p string, t time.Time) bool { func (e *gobEncoder) writeTimeGobProp(p string, t time.Time) bool { return true } func (e *gobEncoder)writeDurationGobProp (p string, d time.Duration) bool { func (e *gobEncoder) writeDurationGobProp(p string, d time.Duration) bool { return true }
-
@@ -170,4 +169,4 @@ func (e *gobEncoder) writeObjectGobValue(o Object) (bool, error) {} return notEmpty, nil } */ */
-
-
-
@@ -15,8 +15,8 @@ func TestMarshalGob(t *testing.T) {wantErr error }{ { name: "empty object", it: &Object{ name: "empty object", it: &Object{ ID: "test", }, want: []byte{},
-
@@ -25,10 +25,10 @@ func TestMarshalGob(t *testing.T) {} for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { buf := bytes.NewBuffer(make([]byte,0)) buf := bytes.NewBuffer(make([]byte, 0)) err := gob.NewEncoder(buf).Encode(tt.it) if !errors.Is(err, tt.wantErr){ if !errors.Is(err, tt.wantErr) { t.Errorf("MarshalGob() error = %s, wantErr %v", err, tt.wantErr) return }
-
-
-
@@ -6,8 +6,8 @@ import () func assertObjectWithTesting(fn canErrorFunc, expected Item) WithObjectFn { return func (p *Object) error { if !assertDeepEquals(fn, p , expected) { return func(p *Object) error { if !assertDeepEquals(fn, p, expected) { return fmt.Errorf("not equal") } return nil
-
@@ -69,8 +69,8 @@ func TestOnObject(t *testing.T) {} func assertActivityWithTesting(fn canErrorFunc, expected Item) WithActivityFn { return func (p *Activity) error { if !assertDeepEquals(fn, p , expected) { return func(p *Activity) error { if !assertDeepEquals(fn, p, expected) { return fmt.Errorf("not equal") } return nil
-
@@ -132,8 +132,8 @@ func TestOnActivity(t *testing.T) {} func assertIntransitiveActivityWithTesting(fn canErrorFunc, expected Item) WithIntransitiveActivityFn { return func (p *IntransitiveActivity) error { if !assertDeepEquals(fn, p , expected) { return func(p *IntransitiveActivity) error { if !assertDeepEquals(fn, p, expected) { return fmt.Errorf("not equal") } return nil
-
@@ -195,8 +195,8 @@ func TestOnIntransitiveActivity(t *testing.T) {} func assertQuestionWithTesting(fn canErrorFunc, expected Item) WithQuestionFn { return func (p *Question) error { if !assertDeepEquals(fn, p , expected) { return func(p *Question) error { if !assertDeepEquals(fn, p, expected) { return fmt.Errorf("not equal") } return nil
-
-
-
@@ -217,7 +217,7 @@ func (i IntransitiveActivity) GobEncode() ([]byte, error) {func (i *IntransitiveActivity) GobDecode([]byte) error { return errors.New(fmt.Sprintf("GobDecode is not implemented for %T", *i)) } */ */ // IntransitiveActivityNew initializes a intransitive activity func IntransitiveActivityNew(id ID, typ ActivityVocabularyType) *IntransitiveActivity {
-
-
-
@@ -90,7 +90,7 @@ func (i IRI) GobEncode() ([]byte, error) {func (i *IRI) GobDecode([]byte) error { return errors.New(fmt.Sprintf("GobDecode is not implemented for %T", *i)) } */ */ // AddPath concatenates el elements as a path to i func (i IRI) AddPath(el ...string) IRI {
-
-
-
@@ -51,7 +51,7 @@ func ItemsEqual(it, with Item) bool {} if it.IsObject() { if ActivityTypes.Contains(with.GetType()) { OnActivity(it, func(i*Activity) error { OnActivity(it, func(i *Activity) error { result = i.Equals(with) return nil })
-
-
-
@@ -132,4 +132,4 @@ func (l Link) GobEncode() ([]byte, error) {func (l *Link) GobDecode([]byte) error { return errors.New(fmt.Sprintf("GobDecode is not implemented for %T", *l)) } */ */
-
-
-
@@ -473,7 +473,6 @@ func TestSource_UnmarshalJSON(t *testing.T) {func TestGetAPSource(t *testing.T) { data := []byte(`{"source": {"content": "test", "mediaType": "text/plain" }}`) par := fastjson.Parser{} val, _ := par.ParseBytes(data) a := GetAPSource(val)
-
-
-
@@ -124,23 +124,23 @@ func TestToOrderedCollectionPage(t *testing.T) {wantErr error }{ "OrderedCollectionPage": { it: new(OrderedCollectionPage), want: new(OrderedCollectionPage), it: new(OrderedCollectionPage), want: new(OrderedCollectionPage), wantErr: nil, }, "OrderedCollection": { it: new(OrderedCollection), want: new(OrderedCollectionPage), it: new(OrderedCollection), want: new(OrderedCollectionPage), wantErr: err, }, "Collection": { it: new(Collection), want: new(OrderedCollectionPage), it: new(Collection), want: new(OrderedCollectionPage), wantErr: err, }, "CollectionPage": { it: new(CollectionPage), want: new(OrderedCollectionPage), it: new(CollectionPage), want: new(OrderedCollectionPage), wantErr: err, }, }
-
@@ -150,7 +150,7 @@ func TestToOrderedCollectionPage(t *testing.T) {if tt.wantErr != nil && err == nil { t.Errorf("ToOrderedCollectionPage() no error returned, wanted error = [%T]%s", tt.wantErr, tt.wantErr) return } } if err != nil { if tt.wantErr == nil { t.Errorf("ToOrderedCollectionPage() returned unexpected error[%T]%s", err, err)
-
-
-
@@ -221,23 +221,23 @@ func TestToOrderedCollection(t *testing.T) {wantErr error }{ "OrderedCollection": { it: new(OrderedCollection), want: new(OrderedCollection), it: new(OrderedCollection), want: new(OrderedCollection), wantErr: nil, }, "OrderedCollectionPage": { it: new(OrderedCollectionPage), want: new(OrderedCollection), it: new(OrderedCollectionPage), want: new(OrderedCollection), wantErr: nil, }, "Collection": { it: new(Collection), want: new(OrderedCollection), it: new(Collection), want: new(OrderedCollection), wantErr: err, }, "CollectionPage": { it: new(CollectionPage), want: new(OrderedCollection), it: new(CollectionPage), want: new(OrderedCollection), wantErr: err, }, }
-
-
-
@@ -46,8 +46,8 @@ func TestPlace_Clean(t *testing.T) {} func assertPlaceWithTesting(fn canErrorFunc, expected *Place) withPlaceFn { return func (p *Place) error { if !assertDeepEquals(fn, p , expected) { return func(p *Place) error { if !assertDeepEquals(fn, p, expected) { return fmt.Errorf("not equal") } return nil
-
@@ -69,22 +69,22 @@ func TestOnPlace(t *testing.T) {}{ { name: "single", args: args{ testPlace, assertPlaceWithTesting }, args: args{testPlace, assertPlaceWithTesting}, wantErr: false, }, { name: "single fails", args: args{ Place{ID: "https://not-equals"}, assertPlaceWithTesting }, args: args{Place{ID: "https://not-equals"}, assertPlaceWithTesting}, wantErr: true, }, { name: "collectionOfPlaces", args: args{ItemCollection{testPlace, testPlace}, assertPlaceWithTesting }, args: args{ItemCollection{testPlace, testPlace}, assertPlaceWithTesting}, wantErr: false, }, { name: "collectionOfPlaces fails", args: args{ ItemCollection{testPlace, Place{ID: "https://not-equals"}}, assertPlaceWithTesting }, args: args{ItemCollection{testPlace, Place{ID: "https://not-equals"}}, assertPlaceWithTesting}, wantErr: true, }, }
-
-
-
@@ -46,8 +46,8 @@ func TestProfile_Clean(t *testing.T) {} func assertProfileWithTesting(fn canErrorFunc, expected *Profile) withProfileFn { return func (p *Profile) error { if !assertDeepEquals(fn, p , expected) { return func(p *Profile) error { if !assertDeepEquals(fn, p, expected) { return fmt.Errorf("not equal") } return nil
-
-
-
@@ -55,7 +55,6 @@ func TestQuestion_GetType(t *testing.T) {} } func TestToQuestion(t *testing.T) { var it Item act := QuestionNew("test")
-
-
-
@@ -37,8 +37,8 @@ func TestTombstone_Clean(t *testing.T) {t.Skipf("TODO") } func assertTombstoneWithTesting(fn canErrorFunc, expected *Tombstone) withTombstoneFn { return func (p *Tombstone) error { if !assertDeepEquals(fn, p , expected) { return func(p *Tombstone) error { if !assertDeepEquals(fn, p, expected) { return fmt.Errorf("not equal") } return nil
-