2018-10-11 09:26:00 +00:00
|
|
|
package activitystreams
|
2017-09-11 21:10:56 +00:00
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
func TestActivityNew(t *testing.T) {
|
2018-03-27 13:06:06 +00:00
|
|
|
var testValue = ObjectID("test")
|
2017-10-02 09:53:09 +00:00
|
|
|
var testType ActivityVocabularyType = "Accept"
|
2017-09-11 21:10:56 +00:00
|
|
|
|
2017-10-03 20:46:03 +00:00
|
|
|
a := ActivityNew(testValue, testType, nil)
|
2018-04-08 16:55:25 +00:00
|
|
|
if a.ID != testValue {
|
|
|
|
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
|
2017-09-11 21:10:56 +00:00
|
|
|
}
|
|
|
|
if a.Type != testType {
|
|
|
|
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, testType)
|
|
|
|
}
|
2017-09-12 08:54:21 +00:00
|
|
|
|
2017-10-03 20:46:03 +00:00
|
|
|
g := ActivityNew(testValue, "", nil)
|
2017-09-12 08:54:21 +00:00
|
|
|
|
2018-04-08 16:55:25 +00:00
|
|
|
if g.ID != testValue {
|
|
|
|
t.Errorf("Activity Id '%v' different than expected '%v'", g.ID, testValue)
|
2017-09-12 08:54:21 +00:00
|
|
|
}
|
|
|
|
if g.Type != ActivityType {
|
|
|
|
t.Errorf("Activity Type '%v' different than expected '%v'", g.Type, ActivityType)
|
|
|
|
}
|
2017-09-11 21:10:56 +00:00
|
|
|
}
|
2017-09-12 08:54:21 +00:00
|
|
|
|
2017-09-12 15:26:37 +00:00
|
|
|
func TestIntransitiveActivityNew(t *testing.T) {
|
2018-03-27 13:06:06 +00:00
|
|
|
var testValue = ObjectID("test")
|
2017-10-02 09:53:09 +00:00
|
|
|
var testType ActivityVocabularyType = "Accept"
|
2017-09-12 15:26:37 +00:00
|
|
|
|
|
|
|
a := IntransitiveActivityNew(testValue, testType)
|
|
|
|
|
2018-04-08 16:55:25 +00:00
|
|
|
if a.ID != testValue {
|
|
|
|
t.Errorf("IntransitiveActivity Id '%v' different than expected '%v'", a.ID, testValue)
|
2017-09-12 15:26:37 +00:00
|
|
|
}
|
|
|
|
if a.Type != testType {
|
|
|
|
t.Errorf("IntransitiveActivity Type '%v' different than expected '%v'", a.Type, testType)
|
|
|
|
}
|
|
|
|
|
|
|
|
g := IntransitiveActivityNew(testValue, "")
|
|
|
|
|
2018-04-08 16:55:25 +00:00
|
|
|
if g.ID != testValue {
|
|
|
|
t.Errorf("IntransitiveActivity Id '%v' different than expected '%v'", g.ID, testValue)
|
2017-09-12 15:26:37 +00:00
|
|
|
}
|
|
|
|
if g.Type != IntransitiveActivityType {
|
|
|
|
t.Errorf("IntransitiveActivity Type '%v' different than expected '%v'", g.Type, IntransitiveActivityType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-12 08:54:21 +00:00
|
|
|
func TestValidActivityType(t *testing.T) {
|
2017-10-02 09:53:09 +00:00
|
|
|
var invalidType ActivityVocabularyType = "RandomType"
|
2017-09-12 08:54:21 +00:00
|
|
|
|
|
|
|
if ValidActivityType(ActivityType) {
|
|
|
|
t.Errorf("Generic Activity Type '%v' should not be valid", ActivityType)
|
|
|
|
}
|
2017-09-15 16:11:31 +00:00
|
|
|
for _, inValidType := range validObjectTypes {
|
|
|
|
if ValidActivityType(inValidType) {
|
2017-10-05 10:38:11 +00:00
|
|
|
t.Errorf("APObject Type '%v' should be invalid", inValidType)
|
2017-09-15 16:11:31 +00:00
|
|
|
}
|
|
|
|
}
|
2017-09-12 08:54:21 +00:00
|
|
|
if ValidActivityType(invalidType) {
|
|
|
|
t.Errorf("Activity Type '%v' should not be valid", invalidType)
|
|
|
|
}
|
|
|
|
for _, validType := range validActivityTypes {
|
|
|
|
if !ValidActivityType(validType) {
|
|
|
|
t.Errorf("Activity Type '%v' should be valid", validType)
|
|
|
|
}
|
|
|
|
}
|
2017-09-12 16:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestAcceptNew(t *testing.T) {
|
2018-03-27 13:06:06 +00:00
|
|
|
var testValue = ObjectID("test")
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2017-10-03 20:46:03 +00:00
|
|
|
a := AcceptNew(testValue, nil)
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2018-04-08 16:55:25 +00:00
|
|
|
if a.ID != testValue {
|
|
|
|
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
|
2017-09-12 16:53:41 +00:00
|
|
|
}
|
|
|
|
if a.Type != AcceptType {
|
|
|
|
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, AcceptType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestAddNew(t *testing.T) {
|
2018-03-27 13:06:06 +00:00
|
|
|
var testValue = ObjectID("test")
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2018-03-27 15:40:25 +00:00
|
|
|
a := AddNew(testValue, nil, nil)
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2018-04-08 16:55:25 +00:00
|
|
|
if a.ID != testValue {
|
|
|
|
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
|
2017-09-12 16:53:41 +00:00
|
|
|
}
|
|
|
|
if a.Type != AddType {
|
|
|
|
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, AddType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestAnnounceNew(t *testing.T) {
|
2018-03-27 13:06:06 +00:00
|
|
|
var testValue = ObjectID("test")
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2017-10-03 20:46:03 +00:00
|
|
|
a := AnnounceNew(testValue, nil)
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2018-04-08 16:55:25 +00:00
|
|
|
if a.ID != testValue {
|
|
|
|
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
|
2017-09-12 16:53:41 +00:00
|
|
|
}
|
|
|
|
if a.Type != AnnounceType {
|
|
|
|
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, AnnounceType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestArriveNew(t *testing.T) {
|
2018-03-27 13:06:06 +00:00
|
|
|
var testValue = ObjectID("test")
|
2017-09-12 16:53:41 +00:00
|
|
|
|
|
|
|
a := ArriveNew(testValue)
|
|
|
|
|
2018-04-08 16:55:25 +00:00
|
|
|
if a.ID != testValue {
|
|
|
|
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
|
2017-09-12 16:53:41 +00:00
|
|
|
}
|
|
|
|
if a.Type != ArriveType {
|
|
|
|
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, ArriveType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestBlockNew(t *testing.T) {
|
2018-03-27 13:06:06 +00:00
|
|
|
var testValue = ObjectID("test")
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2017-10-03 20:46:03 +00:00
|
|
|
a := BlockNew(testValue, nil)
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2018-04-08 16:55:25 +00:00
|
|
|
if a.ID != testValue {
|
|
|
|
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
|
2017-09-12 16:53:41 +00:00
|
|
|
}
|
|
|
|
if a.Type != BlockType {
|
|
|
|
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, BlockType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCreateNew(t *testing.T) {
|
2018-03-27 13:06:06 +00:00
|
|
|
var testValue = ObjectID("test")
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2017-10-03 20:46:03 +00:00
|
|
|
a := CreateNew(testValue, nil)
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2018-04-08 16:55:25 +00:00
|
|
|
if a.ID != testValue {
|
|
|
|
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
|
2017-09-12 16:53:41 +00:00
|
|
|
}
|
|
|
|
if a.Type != CreateType {
|
|
|
|
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, CreateType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDeleteNew(t *testing.T) {
|
2018-03-27 13:06:06 +00:00
|
|
|
var testValue = ObjectID("test")
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2017-10-03 20:46:03 +00:00
|
|
|
a := DeleteNew(testValue, nil)
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2018-04-08 16:55:25 +00:00
|
|
|
if a.ID != testValue {
|
|
|
|
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
|
2017-09-12 16:53:41 +00:00
|
|
|
}
|
|
|
|
if a.Type != DeleteType {
|
|
|
|
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, DeleteType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestDislikeNew(t *testing.T) {
|
2018-03-27 13:06:06 +00:00
|
|
|
var testValue = ObjectID("test")
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2017-10-03 20:46:03 +00:00
|
|
|
a := DislikeNew(testValue, nil)
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2018-04-08 16:55:25 +00:00
|
|
|
if a.ID != testValue {
|
|
|
|
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
|
2017-09-12 16:53:41 +00:00
|
|
|
}
|
|
|
|
if a.Type != DislikeType {
|
|
|
|
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, DislikeType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestFlagNew(t *testing.T) {
|
2018-03-27 13:06:06 +00:00
|
|
|
var testValue = ObjectID("test")
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2017-10-03 20:46:03 +00:00
|
|
|
a := FlagNew(testValue, nil)
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2018-04-08 16:55:25 +00:00
|
|
|
if a.ID != testValue {
|
|
|
|
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
|
2017-09-12 16:53:41 +00:00
|
|
|
}
|
|
|
|
if a.Type != FlagType {
|
|
|
|
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, FlagType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestFollowNew(t *testing.T) {
|
2018-03-27 13:06:06 +00:00
|
|
|
var testValue = ObjectID("test")
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2017-10-03 20:46:03 +00:00
|
|
|
a := FollowNew(testValue, nil)
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2018-04-08 16:55:25 +00:00
|
|
|
if a.ID != testValue {
|
|
|
|
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
|
2017-09-12 16:53:41 +00:00
|
|
|
}
|
|
|
|
if a.Type != FollowType {
|
|
|
|
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, FollowType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestIgnoreNew(t *testing.T) {
|
2018-03-27 13:06:06 +00:00
|
|
|
var testValue = ObjectID("test")
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2017-10-03 20:46:03 +00:00
|
|
|
a := IgnoreNew(testValue, nil)
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2018-04-08 16:55:25 +00:00
|
|
|
if a.ID != testValue {
|
|
|
|
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
|
2017-09-12 16:53:41 +00:00
|
|
|
}
|
|
|
|
if a.Type != IgnoreType {
|
|
|
|
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, IgnoreType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestInviteNew(t *testing.T) {
|
2018-03-27 13:06:06 +00:00
|
|
|
var testValue = ObjectID("test")
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2017-10-03 20:46:03 +00:00
|
|
|
a := InviteNew(testValue, nil)
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2018-04-08 16:55:25 +00:00
|
|
|
if a.ID != testValue {
|
|
|
|
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
|
2017-09-12 16:53:41 +00:00
|
|
|
}
|
|
|
|
if a.Type != InviteType {
|
|
|
|
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, InviteType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestJoinNew(t *testing.T) {
|
2018-03-27 13:06:06 +00:00
|
|
|
var testValue = ObjectID("test")
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2017-10-03 20:46:03 +00:00
|
|
|
a := JoinNew(testValue, nil)
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2018-04-08 16:55:25 +00:00
|
|
|
if a.ID != testValue {
|
|
|
|
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
|
2017-09-12 16:53:41 +00:00
|
|
|
}
|
|
|
|
if a.Type != JoinType {
|
|
|
|
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, JoinType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestLeaveNew(t *testing.T) {
|
2018-03-27 13:06:06 +00:00
|
|
|
var testValue = ObjectID("test")
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2017-10-03 20:46:03 +00:00
|
|
|
a := LeaveNew(testValue, nil)
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2018-04-08 16:55:25 +00:00
|
|
|
if a.ID != testValue {
|
|
|
|
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
|
2017-09-12 16:53:41 +00:00
|
|
|
}
|
|
|
|
if a.Type != LeaveType {
|
|
|
|
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, LeaveType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestLikeNew(t *testing.T) {
|
2018-03-27 13:06:06 +00:00
|
|
|
var testValue = ObjectID("test")
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2017-10-03 20:46:03 +00:00
|
|
|
a := LikeNew(testValue, nil)
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2018-04-08 16:55:25 +00:00
|
|
|
if a.ID != testValue {
|
|
|
|
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
|
2017-09-12 16:53:41 +00:00
|
|
|
}
|
|
|
|
if a.Type != LikeType {
|
|
|
|
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, LikeType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestListenNew(t *testing.T) {
|
2018-03-27 13:06:06 +00:00
|
|
|
var testValue = ObjectID("test")
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2017-10-03 20:46:03 +00:00
|
|
|
a := ListenNew(testValue, nil)
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2018-04-08 16:55:25 +00:00
|
|
|
if a.ID != testValue {
|
|
|
|
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
|
2017-09-12 16:53:41 +00:00
|
|
|
}
|
|
|
|
if a.Type != ListenType {
|
|
|
|
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, ListenType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMoveNew(t *testing.T) {
|
2018-03-27 13:06:06 +00:00
|
|
|
var testValue = ObjectID("test")
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2017-10-03 20:46:03 +00:00
|
|
|
a := MoveNew(testValue, nil)
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2018-04-08 16:55:25 +00:00
|
|
|
if a.ID != testValue {
|
|
|
|
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
|
2017-09-12 16:53:41 +00:00
|
|
|
}
|
|
|
|
if a.Type != MoveType {
|
|
|
|
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, MoveType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestOfferNew(t *testing.T) {
|
2018-03-27 13:06:06 +00:00
|
|
|
var testValue = ObjectID("test")
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2017-10-03 20:46:03 +00:00
|
|
|
a := OfferNew(testValue, nil)
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2018-04-08 16:55:25 +00:00
|
|
|
if a.ID != testValue {
|
|
|
|
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
|
2017-09-12 16:53:41 +00:00
|
|
|
}
|
|
|
|
if a.Type != OfferType {
|
|
|
|
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, OfferType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestQuestionNew(t *testing.T) {
|
2018-03-27 13:06:06 +00:00
|
|
|
var testValue = ObjectID("test")
|
2017-09-12 16:53:41 +00:00
|
|
|
|
|
|
|
a := QuestionNew(testValue)
|
|
|
|
|
2018-04-08 16:55:25 +00:00
|
|
|
if a.ID != testValue {
|
|
|
|
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
|
2017-09-12 16:53:41 +00:00
|
|
|
}
|
|
|
|
if a.Type != QuestionType {
|
|
|
|
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, QuestionType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestRejectNew(t *testing.T) {
|
2018-03-27 13:06:06 +00:00
|
|
|
var testValue = ObjectID("test")
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2017-10-03 20:46:03 +00:00
|
|
|
a := RejectNew(testValue, nil)
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2018-04-08 16:55:25 +00:00
|
|
|
if a.ID != testValue {
|
|
|
|
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
|
2017-09-12 16:53:41 +00:00
|
|
|
}
|
|
|
|
if a.Type != RejectType {
|
|
|
|
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, RejectType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestReadNew(t *testing.T) {
|
2018-03-27 13:06:06 +00:00
|
|
|
var testValue = ObjectID("test")
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2017-10-03 20:46:03 +00:00
|
|
|
a := ReadNew(testValue, nil)
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2018-04-08 16:55:25 +00:00
|
|
|
if a.ID != testValue {
|
|
|
|
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
|
2017-09-12 16:53:41 +00:00
|
|
|
}
|
|
|
|
if a.Type != ReadType {
|
|
|
|
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, ReadType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestRemoveNew(t *testing.T) {
|
2018-03-27 13:06:06 +00:00
|
|
|
var testValue = ObjectID("test")
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2018-03-27 15:40:25 +00:00
|
|
|
a := RemoveNew(testValue, nil, nil)
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2018-04-08 16:55:25 +00:00
|
|
|
if a.ID != testValue {
|
|
|
|
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
|
2017-09-12 16:53:41 +00:00
|
|
|
}
|
|
|
|
if a.Type != RemoveType {
|
|
|
|
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, RemoveType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestTentativeRejectNew(t *testing.T) {
|
2018-03-27 13:06:06 +00:00
|
|
|
var testValue = ObjectID("test")
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2017-10-03 20:46:03 +00:00
|
|
|
a := TentativeRejectNew(testValue, nil)
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2018-04-08 16:55:25 +00:00
|
|
|
if a.ID != testValue {
|
|
|
|
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
|
2017-09-12 16:53:41 +00:00
|
|
|
}
|
|
|
|
if a.Type != TentativeRejectType {
|
|
|
|
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, TentativeRejectType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestTentativeAcceptNew(t *testing.T) {
|
2018-03-27 13:06:06 +00:00
|
|
|
var testValue = ObjectID("test")
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2017-10-03 20:46:03 +00:00
|
|
|
a := TentativeAcceptNew(testValue, nil)
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2018-04-08 16:55:25 +00:00
|
|
|
if a.ID != testValue {
|
|
|
|
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
|
2017-09-12 16:53:41 +00:00
|
|
|
}
|
|
|
|
if a.Type != TentativeAcceptType {
|
|
|
|
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, TentativeAcceptType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestTravelNew(t *testing.T) {
|
2018-03-27 13:06:06 +00:00
|
|
|
var testValue = ObjectID("test")
|
2017-09-12 16:53:41 +00:00
|
|
|
|
|
|
|
a := TravelNew(testValue)
|
|
|
|
|
2018-04-08 16:55:25 +00:00
|
|
|
if a.ID != testValue {
|
|
|
|
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
|
2017-09-12 16:53:41 +00:00
|
|
|
}
|
|
|
|
if a.Type != TravelType {
|
|
|
|
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, TravelType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestUndoNew(t *testing.T) {
|
2018-03-27 13:06:06 +00:00
|
|
|
var testValue = ObjectID("test")
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2017-10-03 20:46:03 +00:00
|
|
|
a := UndoNew(testValue, nil)
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2018-04-08 16:55:25 +00:00
|
|
|
if a.ID != testValue {
|
|
|
|
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
|
2017-09-12 16:53:41 +00:00
|
|
|
}
|
|
|
|
if a.Type != UndoType {
|
|
|
|
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, UndoType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestUpdateNew(t *testing.T) {
|
2018-03-27 13:06:06 +00:00
|
|
|
var testValue = ObjectID("test")
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2017-10-03 20:46:03 +00:00
|
|
|
a := UpdateNew(testValue, nil)
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2018-04-08 16:55:25 +00:00
|
|
|
if a.ID != testValue {
|
|
|
|
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
|
2017-09-12 16:53:41 +00:00
|
|
|
}
|
|
|
|
if a.Type != UpdateType {
|
|
|
|
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, UpdateType)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestViewNew(t *testing.T) {
|
2018-03-27 13:06:06 +00:00
|
|
|
var testValue = ObjectID("test")
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2017-10-03 20:46:03 +00:00
|
|
|
a := ViewNew(testValue, nil)
|
2017-09-12 16:53:41 +00:00
|
|
|
|
2018-04-08 16:55:25 +00:00
|
|
|
if a.ID != testValue {
|
|
|
|
t.Errorf("Activity Id '%v' different than expected '%v'", a.ID, testValue)
|
2017-09-12 16:53:41 +00:00
|
|
|
}
|
|
|
|
if a.Type != ViewType {
|
|
|
|
t.Errorf("Activity Type '%v' different than expected '%v'", a.Type, ViewType)
|
|
|
|
}
|
2017-09-12 20:37:34 +00:00
|
|
|
}
|
2018-06-05 19:54:56 +00:00
|
|
|
|
|
|
|
func TestActivityRecipientsDeduplication(t *testing.T) {
|
|
|
|
bob := PersonNew("bob")
|
|
|
|
alice := PersonNew("alice")
|
|
|
|
foo := OrganizationNew("foo")
|
|
|
|
bar := GroupNew("bar")
|
|
|
|
|
|
|
|
a := ActivityNew("t", "test", nil)
|
|
|
|
|
|
|
|
a.To.Append(bob)
|
|
|
|
a.To.Append(alice)
|
|
|
|
a.To.Append(foo)
|
|
|
|
a.To.Append(bar)
|
|
|
|
if len(a.To) != 4 {
|
|
|
|
t.Errorf("%T.To should have exactly 4(four) elements, not %d", a, len(a.To))
|
|
|
|
}
|
|
|
|
|
|
|
|
a.To.Append(bar)
|
|
|
|
a.To.Append(alice)
|
|
|
|
a.To.Append(foo)
|
|
|
|
a.To.Append(bob)
|
|
|
|
if len(a.To) != 8 {
|
|
|
|
t.Errorf("%T.To should have exactly 8(eight) elements, not %d", a, len(a.To))
|
|
|
|
}
|
|
|
|
|
|
|
|
a.RecipientsDeduplication()
|
|
|
|
if len(a.To) != 4 {
|
|
|
|
t.Errorf("%T.To should have exactly 4(four) elements, not %d", a, len(a.To))
|
|
|
|
}
|
|
|
|
|
|
|
|
b := ActivityNew("t", "test", nil)
|
|
|
|
|
|
|
|
b.To.Append(bar)
|
|
|
|
b.To.Append(alice)
|
|
|
|
b.To.Append(foo)
|
|
|
|
b.To.Append(bob)
|
|
|
|
b.Bto.Append(bar)
|
|
|
|
b.Bto.Append(alice)
|
|
|
|
b.Bto.Append(foo)
|
|
|
|
b.Bto.Append(bob)
|
|
|
|
b.CC.Append(bar)
|
|
|
|
b.CC.Append(alice)
|
|
|
|
b.CC.Append(foo)
|
|
|
|
b.CC.Append(bob)
|
|
|
|
b.BCC.Append(bar)
|
|
|
|
b.BCC.Append(alice)
|
|
|
|
b.BCC.Append(foo)
|
|
|
|
b.BCC.Append(bob)
|
|
|
|
|
|
|
|
b.RecipientsDeduplication()
|
|
|
|
if len(b.To) != 4 {
|
|
|
|
t.Errorf("%T.To should have exactly 4(four) elements, not %d", b, len(b.To))
|
|
|
|
}
|
|
|
|
if len(b.Bto) != 0 {
|
|
|
|
t.Errorf("%T.Bto should have exactly 0(zero) elements, not %d", b, len(b.Bto))
|
|
|
|
}
|
|
|
|
if len(b.CC) != 0 {
|
|
|
|
t.Errorf("%T.CC should have exactly 0(zero) elements, not %d", b, len(b.CC))
|
|
|
|
}
|
|
|
|
if len(b.BCC) != 0 {
|
|
|
|
t.Errorf("%T.BCC should have exactly 0(zero) elements, not %d", b, len(b.BCC))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestBlockRecipientsDeduplication(t *testing.T) {
|
|
|
|
bob := PersonNew("bob")
|
|
|
|
alice := PersonNew("alice")
|
|
|
|
foo := OrganizationNew("foo")
|
|
|
|
bar := GroupNew("bar")
|
|
|
|
|
|
|
|
a := BlockNew("bbb", bob)
|
|
|
|
|
|
|
|
a.To.Append(bob)
|
|
|
|
a.To.Append(alice)
|
|
|
|
a.To.Append(foo)
|
|
|
|
a.To.Append(bar)
|
|
|
|
if len(a.To) != 4 {
|
|
|
|
t.Errorf("%T.To should have exactly 4(four) elements, not %d", a, len(a.To))
|
|
|
|
}
|
|
|
|
|
|
|
|
a.To.Append(bar)
|
|
|
|
a.To.Append(alice)
|
|
|
|
a.To.Append(foo)
|
|
|
|
a.To.Append(bob)
|
|
|
|
if len(a.To) != 8 {
|
|
|
|
t.Errorf("%T.To should have exactly 8(eight) elements, not %d", a, len(a.To))
|
|
|
|
}
|
|
|
|
|
|
|
|
a.RecipientsDeduplication()
|
|
|
|
if len(a.To) != 3 {
|
|
|
|
t.Errorf("%T.To should have exactly 3(four) elements, not %d", a, len(a.To))
|
|
|
|
}
|
|
|
|
|
|
|
|
b := BlockNew("t", bob)
|
|
|
|
|
|
|
|
b.To.Append(bar)
|
|
|
|
b.To.Append(alice)
|
|
|
|
b.To.Append(foo)
|
|
|
|
b.To.Append(bob)
|
|
|
|
b.Bto.Append(bar)
|
|
|
|
b.Bto.Append(alice)
|
|
|
|
b.Bto.Append(foo)
|
|
|
|
b.Bto.Append(bob)
|
|
|
|
b.CC.Append(bar)
|
|
|
|
b.CC.Append(alice)
|
|
|
|
b.CC.Append(foo)
|
|
|
|
b.CC.Append(bob)
|
|
|
|
b.BCC.Append(bar)
|
|
|
|
b.BCC.Append(alice)
|
|
|
|
b.BCC.Append(foo)
|
|
|
|
b.BCC.Append(bob)
|
|
|
|
|
|
|
|
b.RecipientsDeduplication()
|
|
|
|
if len(b.To) != 3 {
|
|
|
|
t.Errorf("%T.To should have exactly 4(four) elements, not %d", b, len(b.To))
|
|
|
|
}
|
|
|
|
if len(b.Bto) != 0 {
|
|
|
|
t.Errorf("%T.Bto should have exactly 0(zero) elements, not %d", b, len(b.Bto))
|
|
|
|
}
|
|
|
|
if len(b.CC) != 0 {
|
|
|
|
t.Errorf("%T.CC should have exactly 0(zero) elements, not %d", b, len(b.CC))
|
|
|
|
}
|
|
|
|
if len(b.BCC) != 0 {
|
|
|
|
t.Errorf("%T.BCC should have exactly 0(zero) elements, not %d", b, len(b.BCC))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestIntransitiveActivityRecipientsDeduplication(t *testing.T) {
|
|
|
|
bob := PersonNew("bob")
|
|
|
|
alice := PersonNew("alice")
|
|
|
|
foo := OrganizationNew("foo")
|
|
|
|
bar := GroupNew("bar")
|
|
|
|
|
|
|
|
a := IntransitiveActivityNew("test", "t")
|
|
|
|
|
|
|
|
a.To.Append(bob)
|
|
|
|
a.To.Append(alice)
|
|
|
|
a.To.Append(foo)
|
|
|
|
a.To.Append(bar)
|
|
|
|
if len(a.To) != 4 {
|
|
|
|
t.Errorf("%T.To should have exactly 4(four) elements, not %d", a, len(a.To))
|
|
|
|
}
|
|
|
|
|
|
|
|
a.To.Append(bar)
|
|
|
|
a.To.Append(alice)
|
|
|
|
a.To.Append(foo)
|
|
|
|
a.To.Append(bob)
|
|
|
|
if len(a.To) != 8 {
|
|
|
|
t.Errorf("%T.To should have exactly 8(eight) elements, not %d", a, len(a.To))
|
|
|
|
}
|
|
|
|
|
|
|
|
a.RecipientsDeduplication()
|
|
|
|
if len(a.To) != 4 {
|
|
|
|
t.Errorf("%T.To should have exactly 4(four) elements, not %d", a, len(a.To))
|
|
|
|
}
|
|
|
|
|
|
|
|
b := ActivityNew("t", "test", nil)
|
|
|
|
|
|
|
|
b.To.Append(bar)
|
|
|
|
b.To.Append(alice)
|
|
|
|
b.To.Append(foo)
|
|
|
|
b.To.Append(bob)
|
|
|
|
b.Bto.Append(bar)
|
|
|
|
b.Bto.Append(alice)
|
|
|
|
b.Bto.Append(foo)
|
|
|
|
b.Bto.Append(bob)
|
|
|
|
b.CC.Append(bar)
|
|
|
|
b.CC.Append(alice)
|
|
|
|
b.CC.Append(foo)
|
|
|
|
b.CC.Append(bob)
|
|
|
|
b.BCC.Append(bar)
|
|
|
|
b.BCC.Append(alice)
|
|
|
|
b.BCC.Append(foo)
|
|
|
|
b.BCC.Append(bob)
|
|
|
|
|
|
|
|
b.RecipientsDeduplication()
|
|
|
|
if len(b.To) != 4 {
|
|
|
|
t.Errorf("%T.To should have exactly 4(four) elements, not %d", b, len(b.To))
|
|
|
|
}
|
|
|
|
if len(b.Bto) != 0 {
|
|
|
|
t.Errorf("%T.Bto should have exactly 0(zero) elements, not %d", b, len(b.Bto))
|
|
|
|
}
|
|
|
|
if len(b.CC) != 0 {
|
|
|
|
t.Errorf("%T.CC should have exactly 0(zero) elements, not %d", b, len(b.CC))
|
|
|
|
}
|
|
|
|
if len(b.BCC) != 0 {
|
|
|
|
t.Errorf("%T.BCC should have exactly 0(zero) elements, not %d", b, len(b.BCC))
|
|
|
|
}
|
|
|
|
}
|
2018-06-09 12:05:46 +00:00
|
|
|
func TestActivity_GetID(t *testing.T) {
|
2018-06-09 11:06:55 +00:00
|
|
|
a := ActivityNew("test", ActivityType, Person{})
|
|
|
|
|
2018-07-25 09:47:03 +00:00
|
|
|
if *a.GetID() != "test" {
|
2018-06-09 12:05:46 +00:00
|
|
|
t.Errorf("%T should return an empty %T object. Received %#v", a, a, a)
|
2018-06-09 11:06:55 +00:00
|
|
|
}
|
|
|
|
}
|
2018-06-09 12:05:46 +00:00
|
|
|
func TestActivity_GetIDGetType(t *testing.T) {
|
2018-06-09 11:06:55 +00:00
|
|
|
a := ActivityNew("test", ActivityType, Person{})
|
|
|
|
|
2018-07-25 09:47:03 +00:00
|
|
|
if *a.GetID() != "test" || a.GetType() != ActivityType {
|
2018-06-09 12:05:46 +00:00
|
|
|
t.Errorf("%T should not return an empty %T object. Received %#v", a, a, a)
|
2018-06-09 11:06:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
func TestActivity_IsLink(t *testing.T) {
|
|
|
|
a := ActivityNew("test", ActivityType, Person{})
|
|
|
|
|
|
|
|
if a.IsLink() {
|
|
|
|
t.Errorf("%T should not respond true to IsLink", a)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func TestActivity_IsObject(t *testing.T) {
|
|
|
|
a := ActivityNew("test", ActivityType, Person{})
|
|
|
|
|
|
|
|
if !a.IsObject() {
|
|
|
|
t.Errorf("%T should respond true to IsObject", a)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func TestIntransitiveActivity_GetLink(t *testing.T) {
|
|
|
|
i := IntransitiveActivityNew("test", QuestionType)
|
|
|
|
|
2018-07-25 09:47:03 +00:00
|
|
|
if *i.GetID() != "test" {
|
2018-06-09 12:05:46 +00:00
|
|
|
t.Errorf("%T should return an empty %T object. Received %#v", i, i, i)
|
2018-06-09 11:06:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
func TestIntransitiveActivity_GetObject(t *testing.T) {
|
|
|
|
i := IntransitiveActivityNew("test", QuestionType)
|
|
|
|
|
2018-07-25 09:47:03 +00:00
|
|
|
if *i.GetID() != "test" || i.GetType() != QuestionType {
|
2018-06-09 12:05:46 +00:00
|
|
|
t.Errorf("%T should not return an empty %T object. Received %#v", i, i, i)
|
2018-06-09 11:06:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
func TestIntransitiveActivity_IsLink(t *testing.T) {
|
|
|
|
i := IntransitiveActivityNew("test", QuestionType)
|
|
|
|
|
|
|
|
if i.IsLink() {
|
|
|
|
t.Errorf("%T should not respond true to IsLink", i)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func TestIntransitiveActivity_IsObject(t *testing.T) {
|
|
|
|
i := IntransitiveActivityNew("test", ActivityType)
|
|
|
|
|
|
|
|
if !i.IsObject() {
|
|
|
|
t.Errorf("%T should respond true to IsObject", i)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
func TestActivity_RecipientsDeduplication(t *testing.T) {
|
|
|
|
t.Skip("See TestDeduplication")
|
|
|
|
}
|
|
|
|
func TestIntransitiveActivity_RecipientsDeduplication(t *testing.T) {
|
|
|
|
t.Skip("See TestDeduplication")
|
|
|
|
}
|
|
|
|
func TestBlock_RecipientsDeduplication(t *testing.T) {
|
|
|
|
t.Skip("See TestDeduplication")
|
|
|
|
}
|