This repository has been archived on 2022-11-27. You can view files and clone it, but cannot push or open issues or pull requests.
activitypub/typer_test.go

168 lines
2.7 KiB
Go
Raw Normal View History

package handlers
import (
"testing"
2022-03-18 13:02:09 +00:00
"github.com/go-ap/activitypub"
)
func TestPathTyper_Type(t *testing.T) {
t.Skipf("TODO")
}
func TestValidActivityCollection(t *testing.T) {
t.Skipf("TODO")
}
func TestValidCollection(t *testing.T) {
t.Skipf("TODO")
}
func TestValidObjectCollection(t *testing.T) {
t.Skipf("TODO")
}
2020-06-15 09:36:15 +00:00
func TestValidCollectionIRI(t *testing.T) {
t.Skipf("TODO")
}
func TestSplit(t *testing.T) {
t.Skipf("TODO")
}
func TestCollectionType_IRI(t *testing.T) {
t.Skipf("TODO")
}
func TestCollectionType_OfActor(t *testing.T) {
t.Skipf("TODO")
}
func TestCollectionTypes_Contains(t *testing.T) {
t.Skipf("TODO")
}
func TestIRIf(t *testing.T) {
type args struct {
i activitypub.IRI
t CollectionType
}
tests := []struct {
name string
args args
want activitypub.IRI
}{
2021-01-24 16:13:42 +00:00
{
name: "empty iri",
args: args{
i: "",
t: "inbox",
},
want: "/inbox",
},
{
name: "plain concat",
args: args{
i: "https://example.com",
t: "inbox",
},
want: "https://example.com/inbox",
},
{
name: "strip root from iri",
args: args{
i: "https://example.com/",
t: "inbox",
},
want: "https://example.com/inbox",
},
{
name: "invalid iri",
args: args{
i: "example.com",
t: "test",
},
want: "example.com/test",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := IRIf(tt.args.i, tt.args.t); got != tt.want {
t.Errorf("IRIf() = %v, want %v", got, tt.want)
}
})
}
}
2021-02-02 13:46:30 +00:00
func TestCollectionType_AddTo(t *testing.T) {
type args struct {
i activitypub.Item
}
2022-03-18 13:02:09 +00:00
var i activitypub.Item
2021-02-02 13:46:30 +00:00
var o *activitypub.Object
tests := []struct {
name string
t CollectionType
args args
want activitypub.IRI
want1 bool
}{
{
2022-03-18 13:02:09 +00:00
name: "simple",
t: "test",
args: args{
2021-02-02 13:46:30 +00:00
i: &activitypub.Object{ID: "http://example.com/addTo"},
},
want: "http://example.com/addTo/test",
want1: false, // this seems to always be false
},
{
2022-03-18 13:02:09 +00:00
name: "on-nil-item",
t: "test",
args: args{
2021-02-02 13:46:30 +00:00
i: i,
},
2022-03-18 13:02:09 +00:00
want: activitypub.NilIRI,
2021-02-02 13:46:30 +00:00
want1: false,
},
{
2022-03-18 13:02:09 +00:00
name: "on-nil",
t: "test",
args: args{
2021-02-02 13:46:30 +00:00
i: nil,
},
2022-03-18 13:02:09 +00:00
want: activitypub.NilIRI,
2021-02-02 13:46:30 +00:00
want1: false,
},
{
2022-03-18 13:02:09 +00:00
name: "on-nil-object",
t: "test",
args: args{
2021-02-02 13:46:30 +00:00
i: o,
},
2022-03-18 13:02:09 +00:00
want: activitypub.NilIRI,
2021-02-02 13:46:30 +00:00
want1: false,
},
{
2022-03-18 13:02:09 +00:00
name: "on-nil-item",
t: "test",
args: args{
2021-02-02 13:46:30 +00:00
i: i,
},
2022-03-18 13:02:09 +00:00
want: activitypub.NilIRI,
2021-02-02 13:46:30 +00:00
want1: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, got1 := tt.t.AddTo(tt.args.i)
if got != tt.want {
t.Errorf("AddTo() got = %v, want %v", got, tt.want)
}
if got1 != tt.want1 {
t.Errorf("AddTo() got1 = %v, want %v", got1, tt.want1)
}
})
}
2022-03-18 13:02:09 +00:00
}