From 43f7a211adf6d4406a90c49ce63b88aa0f6c940d Mon Sep 17 00:00:00 2001 From: Xeronith Date: Fri, 4 Nov 2022 16:57:49 +0330 Subject: [PATCH] test(components): :test_tube: inbox and outbox repository and core --- ...vity_pub_incoming_activity_manager_test.go | 164 +++++ ...vity_pub_outgoing_activity_manager_test.go | 164 +++++ ...pub_incoming_activities_repository_test.go | 575 ++++++++++++++++++ ...pub_outgoing_activities_repository_test.go | 575 ++++++++++++++++++ 4 files changed, 1478 insertions(+) create mode 100644 greataped/components/core/activity_pub_incoming_activity_manager_test.go create mode 100644 greataped/components/core/activity_pub_outgoing_activity_manager_test.go create mode 100644 greataped/components/model/repository/activity_pub_incoming_activities_repository_test.go create mode 100644 greataped/components/model/repository/activity_pub_outgoing_activities_repository_test.go diff --git a/greataped/components/core/activity_pub_incoming_activity_manager_test.go b/greataped/components/core/activity_pub_incoming_activity_manager_test.go new file mode 100644 index 0000000..b9c9381 --- /dev/null +++ b/greataped/components/core/activity_pub_incoming_activity_manager_test.go @@ -0,0 +1,164 @@ +package core_test + +import ( + "testing" + + . "rail.town/infrastructure/components/constants" + . "rail.town/infrastructure/components/contracts" + . "rail.town/infrastructure/components/core" +) + +func TestActivityPubIncomingActivityManager_GetName(test *testing.T) { + manager := Conductor.ActivityPubIncomingActivityManager() + + if manager.Name() != ACTIVITY_PUB_INCOMING_ACTIVITY_MANAGER { + test.Fail() + } +} + +func TestActivityPubIncomingActivityManager_ResolveDependencies(test *testing.T) { + manager := Conductor.ActivityPubIncomingActivityManager() + + if err := manager.ResolveDependencies(); err != nil { + test.Fatal(err) + } +} + +func TestActivityPubIncomingActivityManager_Load(test *testing.T) { + manager := Conductor.ActivityPubIncomingActivityManager() + + if err := manager.Load(); err != nil { + test.Fatal(err) + } +} + +func TestActivityPubIncomingActivityManager_Reload(test *testing.T) { + manager := Conductor.ActivityPubIncomingActivityManager() + + if err := manager.Reload(); err != nil && err != ERROR_OPERATION_NOT_SUPPORTED { + test.Fatal(err) + } +} + +func TestActivityPubIncomingActivityManager_Count(test *testing.T) { + manager := Conductor.ActivityPubIncomingActivityManager() + + _ = manager.Count() +} + +func TestActivityPubIncomingActivityManager_Exists(test *testing.T) { + manager := Conductor.ActivityPubIncomingActivityManager() + + if manager.Exists(0) { + test.FailNow() + } +} + +func TestActivityPubIncomingActivityManager_ListActivityPubIncomingActivities(test *testing.T) { + manager := Conductor.ActivityPubIncomingActivityManager() + + _ = manager.ListActivityPubIncomingActivities(0, 0, "", nil) +} + +func TestActivityPubIncomingActivityManager_GetActivityPubIncomingActivity(test *testing.T) { + manager := Conductor.ActivityPubIncomingActivityManager() + + if activityPubIncomingActivity, err := manager.GetActivityPubIncomingActivity(0, nil); err == nil { + _ = activityPubIncomingActivity + test.FailNow() + } +} + +func TestActivityPubIncomingActivityManager_AddActivityPubIncomingActivity(test *testing.T) { + manager := Conductor.ActivityPubIncomingActivityManager() + + activityPubIncomingActivity, err := manager.AddActivityPubIncomingActivity(0, "unique_identifier", 0, "from", "to", "content", "raw", nil) + if err != nil { + test.Fatal(err) + } + + _ = activityPubIncomingActivity +} + +func TestActivityPubIncomingActivityManager_UpdateActivityPubIncomingActivity(test *testing.T) { + manager := Conductor.ActivityPubIncomingActivityManager() + + activityPubIncomingActivity, err := manager.UpdateActivityPubIncomingActivity(0, 0, "unique_identifier", 0, "from", "to", "content", "raw", nil) + if err != nil { + test.Fatal(err) + } + + _ = activityPubIncomingActivity +} + +func TestActivityPubIncomingActivityManager_RemoveActivityPubIncomingActivity(test *testing.T) { + manager := Conductor.ActivityPubIncomingActivityManager() + + activityPubIncomingActivity, err := manager.RemoveActivityPubIncomingActivity(0, nil) + if err != nil { + test.Fatal(err) + } + + _ = activityPubIncomingActivity +} + +func TestActivityPubIncomingActivityManager_Find(test *testing.T) { + manager := Conductor.ActivityPubIncomingActivityManager() + + activityPubIncomingActivity := manager.Find(0) + if activityPubIncomingActivity == nil { + test.Fail() + } + + _ = activityPubIncomingActivity +} + +func TestActivityPubIncomingActivityManager_ForEach(test *testing.T) { + manager := Conductor.ActivityPubIncomingActivityManager() + + manager.ForEach(func(activityPubIncomingActivity IActivityPubIncomingActivity) { + _ = activityPubIncomingActivity + }) +} + +func TestActivityPubIncomingActivityManager_Filter(test *testing.T) { + manager := Conductor.ActivityPubIncomingActivityManager() + + activityPubIncomingActivities := manager.Filter(func(activityPubIncomingActivity IActivityPubIncomingActivity) bool { + return activityPubIncomingActivity.Id() < 0 + }) + + if activityPubIncomingActivities.IsNotEmpty() { + test.Fail() + } + + _ = activityPubIncomingActivities +} + +func TestActivityPubIncomingActivityManager_Map(test *testing.T) { + manager := Conductor.ActivityPubIncomingActivityManager() + + activityPubIncomingActivities := manager.Map(func(activityPubIncomingActivity IActivityPubIncomingActivity) IActivityPubIncomingActivity { + return activityPubIncomingActivity + }) + + if activityPubIncomingActivities.Count() != manager.Count() { + test.Fail() + } + + _ = activityPubIncomingActivities +} + +func TestActivityPubIncomingActivityManager_ListActivityPubIncomingActivitiesByIdentity(test *testing.T) { + manager := Conductor.ActivityPubIncomingActivityManager() + + _ = manager.ListActivityPubIncomingActivitiesByIdentity(0, 0, 0, "", nil) +} + +func TestActivityPubIncomingActivityManager_ForEachByIdentity(test *testing.T) { + manager := Conductor.ActivityPubIncomingActivityManager() + + manager.ForEachByIdentity(0, func(activityPubIncomingActivity IActivityPubIncomingActivity) { + _ = activityPubIncomingActivity + }) +} diff --git a/greataped/components/core/activity_pub_outgoing_activity_manager_test.go b/greataped/components/core/activity_pub_outgoing_activity_manager_test.go new file mode 100644 index 0000000..ef44c66 --- /dev/null +++ b/greataped/components/core/activity_pub_outgoing_activity_manager_test.go @@ -0,0 +1,164 @@ +package core_test + +import ( + "testing" + + . "rail.town/infrastructure/components/constants" + . "rail.town/infrastructure/components/contracts" + . "rail.town/infrastructure/components/core" +) + +func TestActivityPubOutgoingActivityManager_GetName(test *testing.T) { + manager := Conductor.ActivityPubOutgoingActivityManager() + + if manager.Name() != ACTIVITY_PUB_OUTGOING_ACTIVITY_MANAGER { + test.Fail() + } +} + +func TestActivityPubOutgoingActivityManager_ResolveDependencies(test *testing.T) { + manager := Conductor.ActivityPubOutgoingActivityManager() + + if err := manager.ResolveDependencies(); err != nil { + test.Fatal(err) + } +} + +func TestActivityPubOutgoingActivityManager_Load(test *testing.T) { + manager := Conductor.ActivityPubOutgoingActivityManager() + + if err := manager.Load(); err != nil { + test.Fatal(err) + } +} + +func TestActivityPubOutgoingActivityManager_Reload(test *testing.T) { + manager := Conductor.ActivityPubOutgoingActivityManager() + + if err := manager.Reload(); err != nil && err != ERROR_OPERATION_NOT_SUPPORTED { + test.Fatal(err) + } +} + +func TestActivityPubOutgoingActivityManager_Count(test *testing.T) { + manager := Conductor.ActivityPubOutgoingActivityManager() + + _ = manager.Count() +} + +func TestActivityPubOutgoingActivityManager_Exists(test *testing.T) { + manager := Conductor.ActivityPubOutgoingActivityManager() + + if manager.Exists(0) { + test.FailNow() + } +} + +func TestActivityPubOutgoingActivityManager_ListActivityPubOutgoingActivities(test *testing.T) { + manager := Conductor.ActivityPubOutgoingActivityManager() + + _ = manager.ListActivityPubOutgoingActivities(0, 0, "", nil) +} + +func TestActivityPubOutgoingActivityManager_GetActivityPubOutgoingActivity(test *testing.T) { + manager := Conductor.ActivityPubOutgoingActivityManager() + + if activityPubOutgoingActivity, err := manager.GetActivityPubOutgoingActivity(0, nil); err == nil { + _ = activityPubOutgoingActivity + test.FailNow() + } +} + +func TestActivityPubOutgoingActivityManager_AddActivityPubOutgoingActivity(test *testing.T) { + manager := Conductor.ActivityPubOutgoingActivityManager() + + activityPubOutgoingActivity, err := manager.AddActivityPubOutgoingActivity(0, "unique_identifier", 0, "from", "to", "content", "raw", nil) + if err != nil { + test.Fatal(err) + } + + _ = activityPubOutgoingActivity +} + +func TestActivityPubOutgoingActivityManager_UpdateActivityPubOutgoingActivity(test *testing.T) { + manager := Conductor.ActivityPubOutgoingActivityManager() + + activityPubOutgoingActivity, err := manager.UpdateActivityPubOutgoingActivity(0, 0, "unique_identifier", 0, "from", "to", "content", "raw", nil) + if err != nil { + test.Fatal(err) + } + + _ = activityPubOutgoingActivity +} + +func TestActivityPubOutgoingActivityManager_RemoveActivityPubOutgoingActivity(test *testing.T) { + manager := Conductor.ActivityPubOutgoingActivityManager() + + activityPubOutgoingActivity, err := manager.RemoveActivityPubOutgoingActivity(0, nil) + if err != nil { + test.Fatal(err) + } + + _ = activityPubOutgoingActivity +} + +func TestActivityPubOutgoingActivityManager_Find(test *testing.T) { + manager := Conductor.ActivityPubOutgoingActivityManager() + + activityPubOutgoingActivity := manager.Find(0) + if activityPubOutgoingActivity == nil { + test.Fail() + } + + _ = activityPubOutgoingActivity +} + +func TestActivityPubOutgoingActivityManager_ForEach(test *testing.T) { + manager := Conductor.ActivityPubOutgoingActivityManager() + + manager.ForEach(func(activityPubOutgoingActivity IActivityPubOutgoingActivity) { + _ = activityPubOutgoingActivity + }) +} + +func TestActivityPubOutgoingActivityManager_Filter(test *testing.T) { + manager := Conductor.ActivityPubOutgoingActivityManager() + + activityPubOutgoingActivities := manager.Filter(func(activityPubOutgoingActivity IActivityPubOutgoingActivity) bool { + return activityPubOutgoingActivity.Id() < 0 + }) + + if activityPubOutgoingActivities.IsNotEmpty() { + test.Fail() + } + + _ = activityPubOutgoingActivities +} + +func TestActivityPubOutgoingActivityManager_Map(test *testing.T) { + manager := Conductor.ActivityPubOutgoingActivityManager() + + activityPubOutgoingActivities := manager.Map(func(activityPubOutgoingActivity IActivityPubOutgoingActivity) IActivityPubOutgoingActivity { + return activityPubOutgoingActivity + }) + + if activityPubOutgoingActivities.Count() != manager.Count() { + test.Fail() + } + + _ = activityPubOutgoingActivities +} + +func TestActivityPubOutgoingActivityManager_ListActivityPubOutgoingActivitiesByIdentity(test *testing.T) { + manager := Conductor.ActivityPubOutgoingActivityManager() + + _ = manager.ListActivityPubOutgoingActivitiesByIdentity(0, 0, 0, "", nil) +} + +func TestActivityPubOutgoingActivityManager_ForEachByIdentity(test *testing.T) { + manager := Conductor.ActivityPubOutgoingActivityManager() + + manager.ForEachByIdentity(0, func(activityPubOutgoingActivity IActivityPubOutgoingActivity) { + _ = activityPubOutgoingActivity + }) +} diff --git a/greataped/components/model/repository/activity_pub_incoming_activities_repository_test.go b/greataped/components/model/repository/activity_pub_incoming_activities_repository_test.go new file mode 100644 index 0000000..804d1dd --- /dev/null +++ b/greataped/components/model/repository/activity_pub_incoming_activities_repository_test.go @@ -0,0 +1,575 @@ +package repository_test + +import ( + "testing" + + . "rail.town/infrastructure/components/model/entity" + . "rail.town/infrastructure/components/model/repository" +) + +func TestActivityPubIncomingActivitiesRepository_Add(test *testing.T) { + type arguments struct { + id int64 + identityId int64 + uniqueIdentifier string + timestamp int64 + from string + to string + content string + raw string + } + + testCases := []struct { + name string + expectation bool + arguments arguments + }{ + { + name: "Case1", + expectation: false, + arguments: arguments{ + id: 0, + identityId: 0, + uniqueIdentifier: "unique_identifier", + timestamp: 0, + from: "from", + to: "to", + content: "content", + raw: "raw", + }, + }, + { + name: "Case2", + expectation: false, + arguments: arguments{ + id: 0, + identityId: 0, + uniqueIdentifier: "unique_identifier", + timestamp: 0, + from: "from", + to: "to", + content: "content", + raw: "raw", + }, + }, + { + name: "Case3", + expectation: false, + arguments: arguments{ + id: 0, + identityId: 0, + uniqueIdentifier: "unique_identifier", + timestamp: 0, + from: "from", + to: "to", + content: "content", + raw: "raw", + }, + }, + } + + for _, testCase := range testCases { + test.Run(testCase.name, func(test *testing.T) { + entity := NewActivityPubIncomingActivityEntity(testCase.arguments.id, testCase.arguments.identityId, testCase.arguments.uniqueIdentifier, testCase.arguments.timestamp, testCase.arguments.from, testCase.arguments.to, testCase.arguments.content, testCase.arguments.raw) + if result := ActivityPubIncomingActivities.Add(entity, -1) == nil; result != testCase.expectation { + test.Errorf("ActivityPubIncomingActivities.Add() = %v, expected %v", result, testCase.expectation) + } + }) + } +} + +func TestActivityPubIncomingActivitiesRepository_FetchById(test *testing.T) { + type arguments struct { + id int64 + } + + testCases := []struct { + name string + expectation bool + arguments arguments + }{ + { + name: "Case1", + expectation: false, + arguments: arguments{ + id: 0, + }, + }, + { + name: "Case2", + expectation: false, + arguments: arguments{ + id: 0, + }, + }, + { + name: "Case3", + expectation: false, + arguments: arguments{ + id: 0, + }, + }, + } + + for _, testCase := range testCases { + test.Run(testCase.name, func(test *testing.T) { + entity, err := ActivityPubIncomingActivities.FetchById(testCase.arguments.id) + if result := err == nil; result != testCase.expectation { + test.Errorf("ActivityPubIncomingActivities.FetchById() = %v, expected %v", result, testCase.expectation) + } + + _ = entity + }) + } +} + +func TestActivityPubIncomingActivitiesRepository_Update(test *testing.T) { + type arguments struct { + id int64 + identityId int64 + uniqueIdentifier string + timestamp int64 + from string + to string + content string + raw string + } + + testCases := []struct { + name string + expectation bool + arguments arguments + }{ + { + name: "Case1", + expectation: false, + arguments: arguments{ + id: 0, + identityId: 0, + uniqueIdentifier: "unique_identifier", + timestamp: 0, + from: "from", + to: "to", + content: "content", + raw: "raw", + }, + }, + { + name: "Case2", + expectation: false, + arguments: arguments{ + id: 0, + identityId: 0, + uniqueIdentifier: "unique_identifier", + timestamp: 0, + from: "from", + to: "to", + content: "content", + raw: "raw", + }, + }, + { + name: "Case3", + expectation: false, + arguments: arguments{ + id: 0, + identityId: 0, + uniqueIdentifier: "unique_identifier", + timestamp: 0, + from: "from", + to: "to", + content: "content", + raw: "raw", + }, + }, + } + + for _, testCase := range testCases { + test.Run(testCase.name, func(test *testing.T) { + entity := NewActivityPubIncomingActivityEntity(testCase.arguments.id, testCase.arguments.identityId, testCase.arguments.uniqueIdentifier, testCase.arguments.timestamp, testCase.arguments.from, testCase.arguments.to, testCase.arguments.content, testCase.arguments.raw) + if result := ActivityPubIncomingActivities.Update(entity, -1) == nil; result != testCase.expectation { + test.Errorf("ActivityPubIncomingActivities.Update() = %v, expected %v", result, testCase.expectation) + } + }) + } +} + +func TestActivityPubIncomingActivitiesRepository_Remove(test *testing.T) { + type arguments struct { + id int64 + identityId int64 + uniqueIdentifier string + timestamp int64 + from string + to string + content string + raw string + } + + testCases := []struct { + name string + expectation bool + arguments arguments + }{ + { + name: "Case1", + expectation: false, + arguments: arguments{ + id: 0, + }, + }, + { + name: "Case2", + expectation: false, + arguments: arguments{ + id: 0, + }, + }, + { + name: "Case3", + expectation: false, + arguments: arguments{ + id: 0, + }, + }, + } + + for _, testCase := range testCases { + test.Run(testCase.name, func(test *testing.T) { + entity := NewActivityPubIncomingActivityEntity(testCase.arguments.id, testCase.arguments.identityId, testCase.arguments.uniqueIdentifier, testCase.arguments.timestamp, testCase.arguments.from, testCase.arguments.to, testCase.arguments.content, testCase.arguments.raw) + if result := ActivityPubIncomingActivities.Remove(entity, -1) == nil; result != testCase.expectation { + test.Errorf("ActivityPubIncomingActivities.Remove() = %v, expected %v", result, testCase.expectation) + } + }) + } +} + +func TestActivityPubIncomingActivitiesRepository_FetchAll(test *testing.T) { + entities, err := ActivityPubIncomingActivities.FetchAll() + if err != nil { + test.Fatal(err) + } + + _ = entities +} + +func TestActivityPubIncomingActivitiesRepository_FetchAllByIdentity(test *testing.T) { + type arguments struct { + identityId int64 + } + + testCases := []struct { + name string + expectation bool + arguments arguments + }{ + { + name: "Case1", + expectation: false, + arguments: arguments{ + identityId: 0, + }, + }, + { + name: "Case2", + expectation: false, + arguments: arguments{ + identityId: 0, + }, + }, + { + name: "Case3", + expectation: false, + arguments: arguments{ + identityId: 0, + }, + }, + } + + for _, testCase := range testCases { + test.Run(testCase.name, func(test *testing.T) { + entities, err := ActivityPubIncomingActivities.FetchAllByIdentity(testCase.arguments.identityId) + if result := err == nil; result != testCase.expectation { + test.Errorf("ActivityPubIncomingActivities.FetchAllByIdentity() = %v, expected %v", result, testCase.expectation) + } + + _ = entities + }) + } +} + +func TestActivityPubIncomingActivitiesRepository_UpdateUniqueIdentifier(test *testing.T) { + type arguments struct { + id int64 + uniqueIdentifier string + } + + testCases := []struct { + name string + expectation bool + arguments arguments + }{ + { + name: "Case1", + expectation: false, + arguments: arguments{ + id: 0, + uniqueIdentifier: "unique_identifier", + }, + }, + { + name: "Case2", + expectation: false, + arguments: arguments{ + id: 0, + uniqueIdentifier: "unique_identifier", + }, + }, + { + name: "Case3", + expectation: false, + arguments: arguments{ + id: 0, + uniqueIdentifier: "unique_identifier", + }, + }, + } + + for _, testCase := range testCases { + test.Run(testCase.name, func(test *testing.T) { + if result := ActivityPubIncomingActivities.UpdateUniqueIdentifier(testCase.arguments.id, testCase.arguments.uniqueIdentifier, -1) == nil; result != testCase.expectation { + test.Errorf("ActivityPubIncomingActivities.UpdateUniqueIdentifier() = %v, expected %v", result, testCase.expectation) + } + }) + } +} + +func TestActivityPubIncomingActivitiesRepository_UpdateTimestamp(test *testing.T) { + type arguments struct { + id int64 + timestamp int64 + } + + testCases := []struct { + name string + expectation bool + arguments arguments + }{ + { + name: "Case1", + expectation: false, + arguments: arguments{ + id: 0, + timestamp: 0, + }, + }, + { + name: "Case2", + expectation: false, + arguments: arguments{ + id: 0, + timestamp: 0, + }, + }, + { + name: "Case3", + expectation: false, + arguments: arguments{ + id: 0, + timestamp: 0, + }, + }, + } + + for _, testCase := range testCases { + test.Run(testCase.name, func(test *testing.T) { + if result := ActivityPubIncomingActivities.UpdateTimestamp(testCase.arguments.id, testCase.arguments.timestamp, -1) == nil; result != testCase.expectation { + test.Errorf("ActivityPubIncomingActivities.UpdateTimestamp() = %v, expected %v", result, testCase.expectation) + } + }) + } +} + +func TestActivityPubIncomingActivitiesRepository_UpdateFrom(test *testing.T) { + type arguments struct { + id int64 + from string + } + + testCases := []struct { + name string + expectation bool + arguments arguments + }{ + { + name: "Case1", + expectation: false, + arguments: arguments{ + id: 0, + from: "from", + }, + }, + { + name: "Case2", + expectation: false, + arguments: arguments{ + id: 0, + from: "from", + }, + }, + { + name: "Case3", + expectation: false, + arguments: arguments{ + id: 0, + from: "from", + }, + }, + } + + for _, testCase := range testCases { + test.Run(testCase.name, func(test *testing.T) { + if result := ActivityPubIncomingActivities.UpdateFrom(testCase.arguments.id, testCase.arguments.from, -1) == nil; result != testCase.expectation { + test.Errorf("ActivityPubIncomingActivities.UpdateFrom() = %v, expected %v", result, testCase.expectation) + } + }) + } +} + +func TestActivityPubIncomingActivitiesRepository_UpdateTo(test *testing.T) { + type arguments struct { + id int64 + to string + } + + testCases := []struct { + name string + expectation bool + arguments arguments + }{ + { + name: "Case1", + expectation: false, + arguments: arguments{ + id: 0, + to: "to", + }, + }, + { + name: "Case2", + expectation: false, + arguments: arguments{ + id: 0, + to: "to", + }, + }, + { + name: "Case3", + expectation: false, + arguments: arguments{ + id: 0, + to: "to", + }, + }, + } + + for _, testCase := range testCases { + test.Run(testCase.name, func(test *testing.T) { + if result := ActivityPubIncomingActivities.UpdateTo(testCase.arguments.id, testCase.arguments.to, -1) == nil; result != testCase.expectation { + test.Errorf("ActivityPubIncomingActivities.UpdateTo() = %v, expected %v", result, testCase.expectation) + } + }) + } +} + +func TestActivityPubIncomingActivitiesRepository_UpdateContent(test *testing.T) { + type arguments struct { + id int64 + content string + } + + testCases := []struct { + name string + expectation bool + arguments arguments + }{ + { + name: "Case1", + expectation: false, + arguments: arguments{ + id: 0, + content: "content", + }, + }, + { + name: "Case2", + expectation: false, + arguments: arguments{ + id: 0, + content: "content", + }, + }, + { + name: "Case3", + expectation: false, + arguments: arguments{ + id: 0, + content: "content", + }, + }, + } + + for _, testCase := range testCases { + test.Run(testCase.name, func(test *testing.T) { + if result := ActivityPubIncomingActivities.UpdateContent(testCase.arguments.id, testCase.arguments.content, -1) == nil; result != testCase.expectation { + test.Errorf("ActivityPubIncomingActivities.UpdateContent() = %v, expected %v", result, testCase.expectation) + } + }) + } +} + +func TestActivityPubIncomingActivitiesRepository_UpdateRaw(test *testing.T) { + type arguments struct { + id int64 + raw string + } + + testCases := []struct { + name string + expectation bool + arguments arguments + }{ + { + name: "Case1", + expectation: false, + arguments: arguments{ + id: 0, + raw: "raw", + }, + }, + { + name: "Case2", + expectation: false, + arguments: arguments{ + id: 0, + raw: "raw", + }, + }, + { + name: "Case3", + expectation: false, + arguments: arguments{ + id: 0, + raw: "raw", + }, + }, + } + + for _, testCase := range testCases { + test.Run(testCase.name, func(test *testing.T) { + if result := ActivityPubIncomingActivities.UpdateRaw(testCase.arguments.id, testCase.arguments.raw, -1) == nil; result != testCase.expectation { + test.Errorf("ActivityPubIncomingActivities.UpdateRaw() = %v, expected %v", result, testCase.expectation) + } + }) + } +} diff --git a/greataped/components/model/repository/activity_pub_outgoing_activities_repository_test.go b/greataped/components/model/repository/activity_pub_outgoing_activities_repository_test.go new file mode 100644 index 0000000..abe02ae --- /dev/null +++ b/greataped/components/model/repository/activity_pub_outgoing_activities_repository_test.go @@ -0,0 +1,575 @@ +package repository_test + +import ( + "testing" + + . "rail.town/infrastructure/components/model/entity" + . "rail.town/infrastructure/components/model/repository" +) + +func TestActivityPubOutgoingActivitiesRepository_Add(test *testing.T) { + type arguments struct { + id int64 + identityId int64 + uniqueIdentifier string + timestamp int64 + from string + to string + content string + raw string + } + + testCases := []struct { + name string + expectation bool + arguments arguments + }{ + { + name: "Case1", + expectation: false, + arguments: arguments{ + id: 0, + identityId: 0, + uniqueIdentifier: "unique_identifier", + timestamp: 0, + from: "from", + to: "to", + content: "content", + raw: "raw", + }, + }, + { + name: "Case2", + expectation: false, + arguments: arguments{ + id: 0, + identityId: 0, + uniqueIdentifier: "unique_identifier", + timestamp: 0, + from: "from", + to: "to", + content: "content", + raw: "raw", + }, + }, + { + name: "Case3", + expectation: false, + arguments: arguments{ + id: 0, + identityId: 0, + uniqueIdentifier: "unique_identifier", + timestamp: 0, + from: "from", + to: "to", + content: "content", + raw: "raw", + }, + }, + } + + for _, testCase := range testCases { + test.Run(testCase.name, func(test *testing.T) { + entity := NewActivityPubOutgoingActivityEntity(testCase.arguments.id, testCase.arguments.identityId, testCase.arguments.uniqueIdentifier, testCase.arguments.timestamp, testCase.arguments.from, testCase.arguments.to, testCase.arguments.content, testCase.arguments.raw) + if result := ActivityPubOutgoingActivities.Add(entity, -1) == nil; result != testCase.expectation { + test.Errorf("ActivityPubOutgoingActivities.Add() = %v, expected %v", result, testCase.expectation) + } + }) + } +} + +func TestActivityPubOutgoingActivitiesRepository_FetchById(test *testing.T) { + type arguments struct { + id int64 + } + + testCases := []struct { + name string + expectation bool + arguments arguments + }{ + { + name: "Case1", + expectation: false, + arguments: arguments{ + id: 0, + }, + }, + { + name: "Case2", + expectation: false, + arguments: arguments{ + id: 0, + }, + }, + { + name: "Case3", + expectation: false, + arguments: arguments{ + id: 0, + }, + }, + } + + for _, testCase := range testCases { + test.Run(testCase.name, func(test *testing.T) { + entity, err := ActivityPubOutgoingActivities.FetchById(testCase.arguments.id) + if result := err == nil; result != testCase.expectation { + test.Errorf("ActivityPubOutgoingActivities.FetchById() = %v, expected %v", result, testCase.expectation) + } + + _ = entity + }) + } +} + +func TestActivityPubOutgoingActivitiesRepository_Update(test *testing.T) { + type arguments struct { + id int64 + identityId int64 + uniqueIdentifier string + timestamp int64 + from string + to string + content string + raw string + } + + testCases := []struct { + name string + expectation bool + arguments arguments + }{ + { + name: "Case1", + expectation: false, + arguments: arguments{ + id: 0, + identityId: 0, + uniqueIdentifier: "unique_identifier", + timestamp: 0, + from: "from", + to: "to", + content: "content", + raw: "raw", + }, + }, + { + name: "Case2", + expectation: false, + arguments: arguments{ + id: 0, + identityId: 0, + uniqueIdentifier: "unique_identifier", + timestamp: 0, + from: "from", + to: "to", + content: "content", + raw: "raw", + }, + }, + { + name: "Case3", + expectation: false, + arguments: arguments{ + id: 0, + identityId: 0, + uniqueIdentifier: "unique_identifier", + timestamp: 0, + from: "from", + to: "to", + content: "content", + raw: "raw", + }, + }, + } + + for _, testCase := range testCases { + test.Run(testCase.name, func(test *testing.T) { + entity := NewActivityPubOutgoingActivityEntity(testCase.arguments.id, testCase.arguments.identityId, testCase.arguments.uniqueIdentifier, testCase.arguments.timestamp, testCase.arguments.from, testCase.arguments.to, testCase.arguments.content, testCase.arguments.raw) + if result := ActivityPubOutgoingActivities.Update(entity, -1) == nil; result != testCase.expectation { + test.Errorf("ActivityPubOutgoingActivities.Update() = %v, expected %v", result, testCase.expectation) + } + }) + } +} + +func TestActivityPubOutgoingActivitiesRepository_Remove(test *testing.T) { + type arguments struct { + id int64 + identityId int64 + uniqueIdentifier string + timestamp int64 + from string + to string + content string + raw string + } + + testCases := []struct { + name string + expectation bool + arguments arguments + }{ + { + name: "Case1", + expectation: false, + arguments: arguments{ + id: 0, + }, + }, + { + name: "Case2", + expectation: false, + arguments: arguments{ + id: 0, + }, + }, + { + name: "Case3", + expectation: false, + arguments: arguments{ + id: 0, + }, + }, + } + + for _, testCase := range testCases { + test.Run(testCase.name, func(test *testing.T) { + entity := NewActivityPubOutgoingActivityEntity(testCase.arguments.id, testCase.arguments.identityId, testCase.arguments.uniqueIdentifier, testCase.arguments.timestamp, testCase.arguments.from, testCase.arguments.to, testCase.arguments.content, testCase.arguments.raw) + if result := ActivityPubOutgoingActivities.Remove(entity, -1) == nil; result != testCase.expectation { + test.Errorf("ActivityPubOutgoingActivities.Remove() = %v, expected %v", result, testCase.expectation) + } + }) + } +} + +func TestActivityPubOutgoingActivitiesRepository_FetchAll(test *testing.T) { + entities, err := ActivityPubOutgoingActivities.FetchAll() + if err != nil { + test.Fatal(err) + } + + _ = entities +} + +func TestActivityPubOutgoingActivitiesRepository_FetchAllByIdentity(test *testing.T) { + type arguments struct { + identityId int64 + } + + testCases := []struct { + name string + expectation bool + arguments arguments + }{ + { + name: "Case1", + expectation: false, + arguments: arguments{ + identityId: 0, + }, + }, + { + name: "Case2", + expectation: false, + arguments: arguments{ + identityId: 0, + }, + }, + { + name: "Case3", + expectation: false, + arguments: arguments{ + identityId: 0, + }, + }, + } + + for _, testCase := range testCases { + test.Run(testCase.name, func(test *testing.T) { + entities, err := ActivityPubOutgoingActivities.FetchAllByIdentity(testCase.arguments.identityId) + if result := err == nil; result != testCase.expectation { + test.Errorf("ActivityPubOutgoingActivities.FetchAllByIdentity() = %v, expected %v", result, testCase.expectation) + } + + _ = entities + }) + } +} + +func TestActivityPubOutgoingActivitiesRepository_UpdateUniqueIdentifier(test *testing.T) { + type arguments struct { + id int64 + uniqueIdentifier string + } + + testCases := []struct { + name string + expectation bool + arguments arguments + }{ + { + name: "Case1", + expectation: false, + arguments: arguments{ + id: 0, + uniqueIdentifier: "unique_identifier", + }, + }, + { + name: "Case2", + expectation: false, + arguments: arguments{ + id: 0, + uniqueIdentifier: "unique_identifier", + }, + }, + { + name: "Case3", + expectation: false, + arguments: arguments{ + id: 0, + uniqueIdentifier: "unique_identifier", + }, + }, + } + + for _, testCase := range testCases { + test.Run(testCase.name, func(test *testing.T) { + if result := ActivityPubOutgoingActivities.UpdateUniqueIdentifier(testCase.arguments.id, testCase.arguments.uniqueIdentifier, -1) == nil; result != testCase.expectation { + test.Errorf("ActivityPubOutgoingActivities.UpdateUniqueIdentifier() = %v, expected %v", result, testCase.expectation) + } + }) + } +} + +func TestActivityPubOutgoingActivitiesRepository_UpdateTimestamp(test *testing.T) { + type arguments struct { + id int64 + timestamp int64 + } + + testCases := []struct { + name string + expectation bool + arguments arguments + }{ + { + name: "Case1", + expectation: false, + arguments: arguments{ + id: 0, + timestamp: 0, + }, + }, + { + name: "Case2", + expectation: false, + arguments: arguments{ + id: 0, + timestamp: 0, + }, + }, + { + name: "Case3", + expectation: false, + arguments: arguments{ + id: 0, + timestamp: 0, + }, + }, + } + + for _, testCase := range testCases { + test.Run(testCase.name, func(test *testing.T) { + if result := ActivityPubOutgoingActivities.UpdateTimestamp(testCase.arguments.id, testCase.arguments.timestamp, -1) == nil; result != testCase.expectation { + test.Errorf("ActivityPubOutgoingActivities.UpdateTimestamp() = %v, expected %v", result, testCase.expectation) + } + }) + } +} + +func TestActivityPubOutgoingActivitiesRepository_UpdateFrom(test *testing.T) { + type arguments struct { + id int64 + from string + } + + testCases := []struct { + name string + expectation bool + arguments arguments + }{ + { + name: "Case1", + expectation: false, + arguments: arguments{ + id: 0, + from: "from", + }, + }, + { + name: "Case2", + expectation: false, + arguments: arguments{ + id: 0, + from: "from", + }, + }, + { + name: "Case3", + expectation: false, + arguments: arguments{ + id: 0, + from: "from", + }, + }, + } + + for _, testCase := range testCases { + test.Run(testCase.name, func(test *testing.T) { + if result := ActivityPubOutgoingActivities.UpdateFrom(testCase.arguments.id, testCase.arguments.from, -1) == nil; result != testCase.expectation { + test.Errorf("ActivityPubOutgoingActivities.UpdateFrom() = %v, expected %v", result, testCase.expectation) + } + }) + } +} + +func TestActivityPubOutgoingActivitiesRepository_UpdateTo(test *testing.T) { + type arguments struct { + id int64 + to string + } + + testCases := []struct { + name string + expectation bool + arguments arguments + }{ + { + name: "Case1", + expectation: false, + arguments: arguments{ + id: 0, + to: "to", + }, + }, + { + name: "Case2", + expectation: false, + arguments: arguments{ + id: 0, + to: "to", + }, + }, + { + name: "Case3", + expectation: false, + arguments: arguments{ + id: 0, + to: "to", + }, + }, + } + + for _, testCase := range testCases { + test.Run(testCase.name, func(test *testing.T) { + if result := ActivityPubOutgoingActivities.UpdateTo(testCase.arguments.id, testCase.arguments.to, -1) == nil; result != testCase.expectation { + test.Errorf("ActivityPubOutgoingActivities.UpdateTo() = %v, expected %v", result, testCase.expectation) + } + }) + } +} + +func TestActivityPubOutgoingActivitiesRepository_UpdateContent(test *testing.T) { + type arguments struct { + id int64 + content string + } + + testCases := []struct { + name string + expectation bool + arguments arguments + }{ + { + name: "Case1", + expectation: false, + arguments: arguments{ + id: 0, + content: "content", + }, + }, + { + name: "Case2", + expectation: false, + arguments: arguments{ + id: 0, + content: "content", + }, + }, + { + name: "Case3", + expectation: false, + arguments: arguments{ + id: 0, + content: "content", + }, + }, + } + + for _, testCase := range testCases { + test.Run(testCase.name, func(test *testing.T) { + if result := ActivityPubOutgoingActivities.UpdateContent(testCase.arguments.id, testCase.arguments.content, -1) == nil; result != testCase.expectation { + test.Errorf("ActivityPubOutgoingActivities.UpdateContent() = %v, expected %v", result, testCase.expectation) + } + }) + } +} + +func TestActivityPubOutgoingActivitiesRepository_UpdateRaw(test *testing.T) { + type arguments struct { + id int64 + raw string + } + + testCases := []struct { + name string + expectation bool + arguments arguments + }{ + { + name: "Case1", + expectation: false, + arguments: arguments{ + id: 0, + raw: "raw", + }, + }, + { + name: "Case2", + expectation: false, + arguments: arguments{ + id: 0, + raw: "raw", + }, + }, + { + name: "Case3", + expectation: false, + arguments: arguments{ + id: 0, + raw: "raw", + }, + }, + } + + for _, testCase := range testCases { + test.Run(testCase.name, func(test *testing.T) { + if result := ActivityPubOutgoingActivities.UpdateRaw(testCase.arguments.id, testCase.arguments.raw, -1) == nil; result != testCase.expectation { + test.Errorf("ActivityPubOutgoingActivities.UpdateRaw() = %v, expected %v", result, testCase.expectation) + } + }) + } +}