mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 11:52:25 -05:00
[bugfix] Use gtserror package for WrongType errs (#1930)
* [bugfix] Use gtserror package for WrongType errs * test
This commit is contained in:
parent
e3e0f673cc
commit
d98b6318ac
11 changed files with 112 additions and 89 deletions
|
|
@ -18,48 +18,16 @@
|
|||
package ap_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/superseriousbusiness/activity/streams"
|
||||
"github.com/superseriousbusiness/activity/streams/vocab"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/ap"
|
||||
"github.com/superseriousbusiness/gotosocial/testrig"
|
||||
)
|
||||
|
||||
type NormalizeTestSuite struct {
|
||||
suite.Suite
|
||||
}
|
||||
|
||||
func (suite *NormalizeTestSuite) jsonToType(rawJson string) (vocab.Type, map[string]interface{}) {
|
||||
var raw map[string]interface{}
|
||||
err := json.Unmarshal([]byte(rawJson), &raw)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
t, err := streams.ToType(context.Background(), raw)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return t, raw
|
||||
}
|
||||
|
||||
func (suite *NormalizeTestSuite) typeToJson(t vocab.Type) string {
|
||||
m, err := ap.Serialize(t)
|
||||
if err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
|
||||
b, err := json.MarshalIndent(m, "", " ")
|
||||
if err != nil {
|
||||
suite.FailNow(err.Error())
|
||||
}
|
||||
|
||||
return string(b)
|
||||
APTestSuite
|
||||
}
|
||||
|
||||
func (suite *NormalizeTestSuite) getStatusable() (vocab.ActivityStreamsNote, map[string]interface{}) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue