processor test

This commit is contained in:
tsmethurst 2021-10-15 14:44:34 +02:00
commit 4f4a002846
2 changed files with 176 additions and 1 deletions

View file

@ -96,9 +96,9 @@ func (suite *ProcessingStandardTestSuite) SetupSuite() {
}
func (suite *ProcessingStandardTestSuite) SetupTest() {
testrig.InitTestLog()
suite.config = testrig.NewTestConfig()
suite.db = testrig.NewTestDB()
testrig.InitTestLog()
suite.storage = testrig.NewTestStorage()
suite.typeconverter = testrig.NewTestTypeConverter(suite.db)
@ -149,6 +149,38 @@ func (suite *ProcessingStandardTestSuite) SetupTest() {
return response, nil
}
if req.URL.String() == suite.testAccounts["remote_account_2"].URI {
// the request is for remote account 2
someAccount := suite.testAccounts["remote_account_2"]
someAccountAS, err := suite.typeconverter.AccountToAS(context.Background(), someAccount)
if err != nil {
panic(err)
}
someAccountI, err := streams.Serialize(someAccountAS)
if err != nil {
panic(err)
}
someAccountJson, err := json.Marshal(someAccountI)
if err != nil {
panic(err)
}
responseType := "application/activity+json"
reader := bytes.NewReader(someAccountJson)
readCloser := io.NopCloser(reader)
response := &http.Response{
StatusCode: 200,
Body: readCloser,
ContentLength: int64(len(someAccountJson)),
Header: http.Header{
"content-type": {responseType},
},
}
return response, nil
}
if req.URL.String() == "http://example.org/users/some_user/statuses/afaba698-5740-4e32-a702-af61aa543bc1" {
// the request is for the forwarded message
message := suite.testActivities["forwarded_message"].Activity.GetActivityStreamsObject().At(0).GetActivityStreamsNote()