mstdn/ent.Report
parent
d28393b1dc
commit
7469ffdaeb
|
@ -11,14 +11,14 @@ import (
|
||||||
// See:
|
// See:
|
||||||
// https://docs.joinmastodon.org/entities/Report/
|
// https://docs.joinmastodon.org/entities/Report/
|
||||||
type Report struct {
|
type Report struct {
|
||||||
ID opt.Optional[string] `json:"id"`
|
ID opt.Optional[string] `json:"id,omitempty"`
|
||||||
ActionTaken opt.Optional[bool] `json:"action_taken"`
|
ActionTaken opt.Optional[bool] `json:"action_taken,omitempty"`
|
||||||
ActionTakenAt nul.Nullable[string] `json:"action_taken_at"`
|
ActionTakenAt nul.Nullable[string] `json:"action_taken_at,omitempty"`
|
||||||
Category opt.Optional[string] `json:"category"`
|
Category opt.Optional[string] `json:"category,omitempty"`
|
||||||
Comment opt.Optional[string] `json:"comment"`
|
Comment opt.Optional[string] `json:"comment,omitempty"`
|
||||||
Forwarded opt.Optional[bool] `json:"forwarded"`
|
Forwarded opt.Optional[bool] `json:"forwarded,omitempty"`
|
||||||
CreatedAt opt.Optional[string] `json:"created_at"`
|
CreatedAt opt.Optional[string] `json:"created_at,omitempty"`
|
||||||
StatusIDs nul.Nullable[jsonstr.Strings] `json:"status_ids"`
|
StatusIDs nul.Nullable[jsonstr.Strings] `json:"status_ids,omitempty"`
|
||||||
RuleIDs nul.Nullable[jsonstr.Strings] `json:"rule_ids"`
|
RuleIDs nul.Nullable[jsonstr.Strings] `json:"rule_ids,omitempty"`
|
||||||
TargetAccount Account `json:"target_account"`
|
TargetAccount opt.Optional[Account] `json:"target_account,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,7 @@ package ent_test
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"encoding/json"
|
"github.com/reiver/go-json"
|
||||||
|
|
||||||
"github.com/reiver/go-jsonint"
|
|
||||||
"github.com/reiver/go-jsonpp"
|
"github.com/reiver/go-jsonpp"
|
||||||
"github.com/reiver/go-jsonstr"
|
"github.com/reiver/go-jsonstr"
|
||||||
"github.com/reiver/go-nul"
|
"github.com/reiver/go-nul"
|
||||||
|
@ -31,32 +29,7 @@ func TestReport_MarshalJSON(t *testing.T) {
|
||||||
CreatedAt: opt.Something("2023-09-27T00:31:59Z"),
|
CreatedAt: opt.Something("2023-09-27T00:31:59Z"),
|
||||||
StatusIDs: nul.Null[jsonstr.Strings](),
|
StatusIDs: nul.Null[jsonstr.Strings](),
|
||||||
RuleIDs: nul.Null[jsonstr.Strings](),
|
RuleIDs: nul.Null[jsonstr.Strings](),
|
||||||
TargetAccount: ent.Account{
|
TargetAccount: opt.Something(demoAccount1()),
|
||||||
ID: opt.Something("12345"),
|
|
||||||
UserName: opt.Something("joeblow"),
|
|
||||||
Acct: opt.Something("joeblow@example.com"),
|
|
||||||
URL: opt.Something("https://example.com/@joeblow"),
|
|
||||||
URI: opt.Something("https://example.com/users/joeblow"),
|
|
||||||
DisplayName: opt.Something("Joe Blow :-)"),
|
|
||||||
Note: opt.Something("<p>I came. I saw. I conquered!</p>"),
|
|
||||||
Avatar: opt.Something("https://files.example.com/avatar/joeblow.png"),
|
|
||||||
AvatarStatic: opt.Something("https://files.example.com/avatar-static/joeblow.png"),
|
|
||||||
Header: opt.Something("https://files.example.com/header/joeblow.png"),
|
|
||||||
HeaderStatic: opt.Something("https://files.example.com/header-static/joeblow/png"),
|
|
||||||
//Fields []Field `json:"fields"`
|
|
||||||
//Emojis []CustomEmoji `json:"emojis"`
|
|
||||||
Locked: opt.Something(false),
|
|
||||||
Bot: opt.Something(false),
|
|
||||||
Group: opt.Something(false),
|
|
||||||
Discoverable: nul.Something(true),
|
|
||||||
CreatedAt: opt.Something("2017-02-08T02:00:53.274Z"),
|
|
||||||
LastStatusAt: nul.Something("2023-09-27T00:31:59Z"),
|
|
||||||
StatusesCount: opt.Something(jsonint.Int64(9876543210)),
|
|
||||||
FollowersCount: opt.Something(jsonint.Int64(12345)),
|
|
||||||
FollowingCount: opt.Something(jsonint.Int64(210)),
|
|
||||||
NoIndex: nul.Nothing[bool](),
|
|
||||||
//Roles []Role `json:"roles"`
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Expected :
|
Expected :
|
||||||
`{`+
|
`{`+
|
||||||
|
@ -78,51 +51,7 @@ func TestReport_MarshalJSON(t *testing.T) {
|
||||||
`,`+
|
`,`+
|
||||||
`"rule_ids":null`+
|
`"rule_ids":null`+
|
||||||
`,`+
|
`,`+
|
||||||
`"target_account":{`+
|
`"target_account":`+toJSON(demoAccount1())+
|
||||||
`"id":"12345"`+
|
|
||||||
`,`+
|
|
||||||
`"username":"joeblow"`+
|
|
||||||
`,`+
|
|
||||||
`"acct":"joeblow@example.com"`+
|
|
||||||
`,`+
|
|
||||||
`"url":"https://example.com/@joeblow"`+
|
|
||||||
`,`+
|
|
||||||
`"uri":"https://example.com/users/joeblow"`+
|
|
||||||
`,`+
|
|
||||||
`"display_name":"Joe Blow :-)"`+
|
|
||||||
`,`+
|
|
||||||
`"note":"\u003cp\u003eI came. I saw. I conquered!\u003c/p\u003e"`+
|
|
||||||
`,`+
|
|
||||||
`"avatar":"https://files.example.com/avatar/joeblow.png"`+
|
|
||||||
`,`+
|
|
||||||
`"avatar_static":"https://files.example.com/avatar-static/joeblow.png"`+
|
|
||||||
`,`+
|
|
||||||
`"header":"https://files.example.com/header/joeblow.png"`+
|
|
||||||
`,`+
|
|
||||||
`"header_static":"https://files.example.com/header-static/joeblow/png"`+
|
|
||||||
`,`+
|
|
||||||
`"fields":[]`+
|
|
||||||
`,`+
|
|
||||||
`"emojis":[]`+
|
|
||||||
`,`+
|
|
||||||
`"locked":false`+
|
|
||||||
`,`+
|
|
||||||
`"bot":false`+
|
|
||||||
`,`+
|
|
||||||
`"group":false`+
|
|
||||||
`,`+
|
|
||||||
`"discoverable":true`+
|
|
||||||
`,`+
|
|
||||||
`"created_at":"2017-02-08T02:00:53.274Z"`+
|
|
||||||
`,`+
|
|
||||||
`"last_status_at":"2023-09-27T00:31:59Z"`+
|
|
||||||
`,`+
|
|
||||||
`"statuses_count":9876543210`+
|
|
||||||
`,`+
|
|
||||||
`"followers_count":12345`+
|
|
||||||
`,`+
|
|
||||||
`"following_count":210`+
|
|
||||||
`}`+
|
|
||||||
`}`,
|
`}`,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -145,32 +74,7 @@ func TestReport_MarshalJSON(t *testing.T) {
|
||||||
CreatedAt: opt.Something("2023-09-27T00:31:59Z"),
|
CreatedAt: opt.Something("2023-09-27T00:31:59Z"),
|
||||||
StatusIDs: nul.Null[jsonstr.Strings](),
|
StatusIDs: nul.Null[jsonstr.Strings](),
|
||||||
RuleIDs: nul.Null[jsonstr.Strings](),
|
RuleIDs: nul.Null[jsonstr.Strings](),
|
||||||
TargetAccount: ent.Account{
|
TargetAccount: opt.Something(demoAccount1()),
|
||||||
ID: opt.Something("12345"),
|
|
||||||
UserName: opt.Something("joeblow"),
|
|
||||||
Acct: opt.Something("joeblow@example.com"),
|
|
||||||
URL: opt.Something("https://example.com/@joeblow"),
|
|
||||||
URI: opt.Something("https://example.com/users/joeblow"),
|
|
||||||
DisplayName: opt.Something("Joe Blow :-)"),
|
|
||||||
Note: opt.Something("<p>I came. I saw. I conquered!</p>"),
|
|
||||||
Avatar: opt.Something("https://files.example.com/avatar/joeblow.png"),
|
|
||||||
AvatarStatic: opt.Something("https://files.example.com/avatar-static/joeblow.png"),
|
|
||||||
Header: opt.Something("https://files.example.com/header/joeblow.png"),
|
|
||||||
HeaderStatic: opt.Something("https://files.example.com/header-static/joeblow/png"),
|
|
||||||
//Fields []Field `json:"fields"`
|
|
||||||
//Emojis []CustomEmoji `json:"emojis"`
|
|
||||||
Locked: opt.Something(false),
|
|
||||||
Bot: opt.Something(false),
|
|
||||||
Group: opt.Something(false),
|
|
||||||
Discoverable: nul.Something(true),
|
|
||||||
CreatedAt: opt.Something("2017-02-08T02:00:53.274Z"),
|
|
||||||
LastStatusAt: nul.Something("2023-09-27T00:31:59Z"),
|
|
||||||
StatusesCount: opt.Something(jsonint.Int64(9876543210)),
|
|
||||||
FollowersCount: opt.Something(jsonint.Int64(12345)),
|
|
||||||
FollowingCount: opt.Something(jsonint.Int64(210)),
|
|
||||||
NoIndex: nul.Nothing[bool](),
|
|
||||||
//Roles []Role `json:"roles"`
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Expected :
|
Expected :
|
||||||
`{`+
|
`{`+
|
||||||
|
@ -192,51 +96,7 @@ func TestReport_MarshalJSON(t *testing.T) {
|
||||||
`,`+
|
`,`+
|
||||||
`"rule_ids":null`+
|
`"rule_ids":null`+
|
||||||
`,`+
|
`,`+
|
||||||
`"target_account":{`+
|
`"target_account":`+toJSON(demoAccount1())+
|
||||||
`"id":"12345"`+
|
|
||||||
`,`+
|
|
||||||
`"username":"joeblow"`+
|
|
||||||
`,`+
|
|
||||||
`"acct":"joeblow@example.com"`+
|
|
||||||
`,`+
|
|
||||||
`"url":"https://example.com/@joeblow"`+
|
|
||||||
`,`+
|
|
||||||
`"uri":"https://example.com/users/joeblow"`+
|
|
||||||
`,`+
|
|
||||||
`"display_name":"Joe Blow :-)"`+
|
|
||||||
`,`+
|
|
||||||
`"note":"\u003cp\u003eI came. I saw. I conquered!\u003c/p\u003e"`+
|
|
||||||
`,`+
|
|
||||||
`"avatar":"https://files.example.com/avatar/joeblow.png"`+
|
|
||||||
`,`+
|
|
||||||
`"avatar_static":"https://files.example.com/avatar-static/joeblow.png"`+
|
|
||||||
`,`+
|
|
||||||
`"header":"https://files.example.com/header/joeblow.png"`+
|
|
||||||
`,`+
|
|
||||||
`"header_static":"https://files.example.com/header-static/joeblow/png"`+
|
|
||||||
`,`+
|
|
||||||
`"fields":[]`+
|
|
||||||
`,`+
|
|
||||||
`"emojis":[]`+
|
|
||||||
`,`+
|
|
||||||
`"locked":false`+
|
|
||||||
`,`+
|
|
||||||
`"bot":false`+
|
|
||||||
`,`+
|
|
||||||
`"group":false`+
|
|
||||||
`,`+
|
|
||||||
`"discoverable":true`+
|
|
||||||
`,`+
|
|
||||||
`"created_at":"2017-02-08T02:00:53.274Z"`+
|
|
||||||
`,`+
|
|
||||||
`"last_status_at":"2023-09-27T00:31:59Z"`+
|
|
||||||
`,`+
|
|
||||||
`"statuses_count":9876543210`+
|
|
||||||
`,`+
|
|
||||||
`"followers_count":12345`+
|
|
||||||
`,`+
|
|
||||||
`"following_count":210`+
|
|
||||||
`}`+
|
|
||||||
`}`,
|
`}`,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -259,32 +119,7 @@ func TestReport_MarshalJSON(t *testing.T) {
|
||||||
CreatedAt: opt.Something("2023-09-27T00:31:59Z"),
|
CreatedAt: opt.Something("2023-09-27T00:31:59Z"),
|
||||||
StatusIDs: nul.Null[jsonstr.Strings](),
|
StatusIDs: nul.Null[jsonstr.Strings](),
|
||||||
RuleIDs: nul.Null[jsonstr.Strings](),
|
RuleIDs: nul.Null[jsonstr.Strings](),
|
||||||
TargetAccount: ent.Account{
|
TargetAccount: opt.Something(demoAccount1()),
|
||||||
ID: opt.Something("12345"),
|
|
||||||
UserName: opt.Something("joeblow"),
|
|
||||||
Acct: opt.Something("joeblow@example.com"),
|
|
||||||
URL: opt.Something("https://example.com/@joeblow"),
|
|
||||||
URI: opt.Something("https://example.com/users/joeblow"),
|
|
||||||
DisplayName: opt.Something("Joe Blow :-)"),
|
|
||||||
Note: opt.Something("<p>I came. I saw. I conquered!</p>"),
|
|
||||||
Avatar: opt.Something("https://files.example.com/avatar/joeblow.png"),
|
|
||||||
AvatarStatic: opt.Something("https://files.example.com/avatar-static/joeblow.png"),
|
|
||||||
Header: opt.Something("https://files.example.com/header/joeblow.png"),
|
|
||||||
HeaderStatic: opt.Something("https://files.example.com/header-static/joeblow/png"),
|
|
||||||
//Fields []Field `json:"fields"`
|
|
||||||
//Emojis []CustomEmoji `json:"emojis"`
|
|
||||||
Locked: opt.Something(false),
|
|
||||||
Bot: opt.Something(false),
|
|
||||||
Group: opt.Something(false),
|
|
||||||
Discoverable: nul.Something(true),
|
|
||||||
CreatedAt: opt.Something("2017-02-08T02:00:53.274Z"),
|
|
||||||
LastStatusAt: nul.Something("2023-09-27T00:31:59Z"),
|
|
||||||
StatusesCount: opt.Something(jsonint.Int64(9876543210)),
|
|
||||||
FollowersCount: opt.Something(jsonint.Int64(12345)),
|
|
||||||
FollowingCount: opt.Something(jsonint.Int64(210)),
|
|
||||||
NoIndex: nul.Nothing[bool](),
|
|
||||||
//Roles []Role `json:"roles"`
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Expected :
|
Expected :
|
||||||
`{`+
|
`{`+
|
||||||
|
@ -306,58 +141,14 @@ func TestReport_MarshalJSON(t *testing.T) {
|
||||||
`,`+
|
`,`+
|
||||||
`"rule_ids":null`+
|
`"rule_ids":null`+
|
||||||
`,`+
|
`,`+
|
||||||
`"target_account":{`+
|
`"target_account":`+toJSON(demoAccount1())+
|
||||||
`"id":"12345"`+
|
|
||||||
`,`+
|
|
||||||
`"username":"joeblow"`+
|
|
||||||
`,`+
|
|
||||||
`"acct":"joeblow@example.com"`+
|
|
||||||
`,`+
|
|
||||||
`"url":"https://example.com/@joeblow"`+
|
|
||||||
`,`+
|
|
||||||
`"uri":"https://example.com/users/joeblow"`+
|
|
||||||
`,`+
|
|
||||||
`"display_name":"Joe Blow :-)"`+
|
|
||||||
`,`+
|
|
||||||
`"note":"\u003cp\u003eI came. I saw. I conquered!\u003c/p\u003e"`+
|
|
||||||
`,`+
|
|
||||||
`"avatar":"https://files.example.com/avatar/joeblow.png"`+
|
|
||||||
`,`+
|
|
||||||
`"avatar_static":"https://files.example.com/avatar-static/joeblow.png"`+
|
|
||||||
`,`+
|
|
||||||
`"header":"https://files.example.com/header/joeblow.png"`+
|
|
||||||
`,`+
|
|
||||||
`"header_static":"https://files.example.com/header-static/joeblow/png"`+
|
|
||||||
`,`+
|
|
||||||
`"fields":[]`+
|
|
||||||
`,`+
|
|
||||||
`"emojis":[]`+
|
|
||||||
`,`+
|
|
||||||
`"locked":false`+
|
|
||||||
`,`+
|
|
||||||
`"bot":false`+
|
|
||||||
`,`+
|
|
||||||
`"group":false`+
|
|
||||||
`,`+
|
|
||||||
`"discoverable":true`+
|
|
||||||
`,`+
|
|
||||||
`"created_at":"2017-02-08T02:00:53.274Z"`+
|
|
||||||
`,`+
|
|
||||||
`"last_status_at":"2023-09-27T00:31:59Z"`+
|
|
||||||
`,`+
|
|
||||||
`"statuses_count":9876543210`+
|
|
||||||
`,`+
|
|
||||||
`"followers_count":12345`+
|
|
||||||
`,`+
|
|
||||||
`"following_count":210`+
|
|
||||||
`}`+
|
|
||||||
`}`,
|
`}`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for testNumber, test := range tests {
|
for testNumber, test := range tests {
|
||||||
|
|
||||||
actualBytes, err := json.Marshal(test.Report)
|
actualBytes, err := json.Marshal(&test.Report)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
t.Errorf("For test #%d, did not expect an error but actually got one.", testNumber)
|
t.Errorf("For test #%d, did not expect an error but actually got one.", testNumber)
|
||||||
t.Logf("ERROR: (%T) %s", err, err)
|
t.Logf("ERROR: (%T) %s", err, err)
|
||||||
|
|
Loading…
Reference in New Issue