diff --git a/ent/account.go b/ent/account.go index c3d09cc..e6a77da 100644 --- a/ent/account.go +++ b/ent/account.go @@ -388,7 +388,6 @@ func (receiver Account) MarshalJSON() ([]byte, error) { } } - buffer = append(buffer, "}"...) return buffer, nil diff --git a/ent/account_marshaljson_test.go b/ent/account_marshaljson_test.go index 9a66f89..f437671 100644 --- a/ent/account_marshaljson_test.go +++ b/ent/account_marshaljson_test.go @@ -92,6 +92,2010 @@ func TestAccount_MarshalJSON(t *testing.T) { `"following_count":355`+ `}`, }, + + + + + + + + + + { + Account: ent.Account{ + ID: opt.Something("47"), + 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("
Hello world!
"), + 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 + //Emojis + Locked: opt.Something(true), + Bot: opt.Something(false), + Group: opt.Something(false), + Discoverable: nul.Null[bool](), + CreatedAt: opt.Something("2023-09-27T22:06:19Z"), + LastStatusAt: nul.Null[string](), + StatusesCount: opt.Something(jsonint.Int64(123)), + FollowersCount: opt.Something(jsonint.Int64(24789)), + FollowingCount: opt.Something(jsonint.Int64(355)), + //Roles + //MuteExpiresAt + }, + + Expected: `{`+ + `"id":"47"`+ + `,`+ + `"username":"joeblow"`+ + `,`+ + `"acct":"joeblow@example.com"`+ + `,`+ + `"url":"https://example.com/@joeblow"`+ + `,`+ + `"uri":"https://example.com/users/joeblow"`+ + `,`+ + `"display_name":"Joe Blow :-)"`+ + `,`+ + `"note":"\u003cp\u003eHello world!\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":true`+ + `,`+ + `"bot":false`+ + `,`+ + `"group":false`+ + `,`+ + `"discoverable":null`+ + `,`+ + `"created_at":"2023-09-27T22:06:19Z"`+ + `,`+ + `"last_status_at":null`+ + `,`+ + `"statuses_count":123`+ + `,`+ + `"followers_count":24789`+ + `,`+ + `"following_count":355`+ + `}`, + }, + + + + { + Account: ent.Account{ + ID: opt.Something("47"), + 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("Hello world!
"), + 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 + //Emojis + Locked: opt.Something(false), + Bot: opt.Something(true), + Group: opt.Something(false), + Discoverable: nul.Null[bool](), + CreatedAt: opt.Something("2023-09-27T22:06:19Z"), + LastStatusAt: nul.Null[string](), + StatusesCount: opt.Something(jsonint.Int64(123)), + FollowersCount: opt.Something(jsonint.Int64(24789)), + FollowingCount: opt.Something(jsonint.Int64(355)), + //Roles + //MuteExpiresAt + }, + + Expected: `{`+ + `"id":"47"`+ + `,`+ + `"username":"joeblow"`+ + `,`+ + `"acct":"joeblow@example.com"`+ + `,`+ + `"url":"https://example.com/@joeblow"`+ + `,`+ + `"uri":"https://example.com/users/joeblow"`+ + `,`+ + `"display_name":"Joe Blow :-)"`+ + `,`+ + `"note":"\u003cp\u003eHello world!\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":true`+ + `,`+ + `"group":false`+ + `,`+ + `"discoverable":null`+ + `,`+ + `"created_at":"2023-09-27T22:06:19Z"`+ + `,`+ + `"last_status_at":null`+ + `,`+ + `"statuses_count":123`+ + `,`+ + `"followers_count":24789`+ + `,`+ + `"following_count":355`+ + `}`, + }, + + + + { + Account: ent.Account{ + ID: opt.Something("47"), + 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("Hello world!
"), + 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 + //Emojis + Locked: opt.Something(false), + Bot: opt.Something(false), + Group: opt.Something(true), + Discoverable: nul.Null[bool](), + CreatedAt: opt.Something("2023-09-27T22:06:19Z"), + LastStatusAt: nul.Null[string](), + StatusesCount: opt.Something(jsonint.Int64(123)), + FollowersCount: opt.Something(jsonint.Int64(24789)), + FollowingCount: opt.Something(jsonint.Int64(355)), + //Roles + //MuteExpiresAt + }, + + Expected: `{`+ + `"id":"47"`+ + `,`+ + `"username":"joeblow"`+ + `,`+ + `"acct":"joeblow@example.com"`+ + `,`+ + `"url":"https://example.com/@joeblow"`+ + `,`+ + `"uri":"https://example.com/users/joeblow"`+ + `,`+ + `"display_name":"Joe Blow :-)"`+ + `,`+ + `"note":"\u003cp\u003eHello world!\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":true`+ + `,`+ + `"discoverable":null`+ + `,`+ + `"created_at":"2023-09-27T22:06:19Z"`+ + `,`+ + `"last_status_at":null`+ + `,`+ + `"statuses_count":123`+ + `,`+ + `"followers_count":24789`+ + `,`+ + `"following_count":355`+ + `}`, + }, + + + + + + + + + { + Account: ent.Account{ + ID: opt.Something("2737523"), + UserName: opt.Something("janedoe"), + Acct: opt.Something("janedoe@something.example"), + URL: opt.Something("https://something.example/@janedoe"), + URI: opt.Something("https://something.example/~janedoe"), + DisplayName: opt.Something("Jane Doe <3"), + Note: opt.Something("Hello world!
"), + Avatar: opt.Something("https://files.example.com/avatar/janedoe.png"), + AvatarStatic: opt.Something("https://files.example.com/avatar-static/janedoe.png"), + Header: opt.Something("https://files.example.com/header/janedoe.png"), + HeaderStatic: opt.Something("https://files.example.com/header-static/janedoe.png"), + //Fields + //Emojis + Locked: opt.Something(false), + Bot: opt.Something(false), + Group: opt.Something(false), + Discoverable: nul.Something(false), + CreatedAt: opt.Something("2023-09-27T22:06:19Z"), + LastStatusAt: nul.Null[string](), + StatusesCount: opt.Something(jsonint.Int64(123)), + FollowersCount: opt.Something(jsonint.Int64(24789)), + FollowingCount: opt.Something(jsonint.Int64(355)), + //Roles + //MuteExpiresAt + }, + + Expected: `{`+ + `"id":"2737523"`+ + `,`+ + `"username":"janedoe"`+ + `,`+ + `"acct":"janedoe@something.example"`+ + `,`+ + `"url":"https://something.example/@janedoe"`+ + `,`+ + `"uri":"https://something.example/~janedoe"`+ + `,`+ + `"display_name":"Jane Doe \u0026lt;3"`+ + `,`+ + `"note":"\u003cp\u003eHello world!\u003c/p\u003e"`+ + `,`+ + `"avatar":"https://files.example.com/avatar/janedoe.png"`+ + `,`+ + `"avatar_static":"https://files.example.com/avatar-static/janedoe.png"`+ + `,`+ + `"header":"https://files.example.com/header/janedoe.png"`+ + `,`+ + `"header_static":"https://files.example.com/header-static/janedoe.png"`+ + `,`+ + `"fields":[]`+ + `,`+ + `"emojis":[]`+ + `,`+ + `"locked":false`+ + `,`+ + `"bot":false`+ + `,`+ + `"group":false`+ + `,`+ + `"discoverable":false`+ + `,`+ + `"created_at":"2023-09-27T22:06:19Z"`+ + `,`+ + `"last_status_at":null`+ + `,`+ + `"statuses_count":123`+ + `,`+ + `"followers_count":24789`+ + `,`+ + `"following_count":355`+ + `}`, + }, + + + + { + Account: ent.Account{ + ID: opt.Something("2737523"), + UserName: opt.Something("janedoe"), + Acct: opt.Something("janedoe@something.example"), + URL: opt.Something("https://something.example/@janedoe"), + URI: opt.Something("https://something.example/~janedoe"), + DisplayName: opt.Something("Jane Doe <3"), + Note: opt.Something("Hello world!
"), + Avatar: opt.Something("https://files.example.com/avatar/janedoe.png"), + AvatarStatic: opt.Something("https://files.example.com/avatar-static/janedoe.png"), + Header: opt.Something("https://files.example.com/header/janedoe.png"), + HeaderStatic: opt.Something("https://files.example.com/header-static/janedoe.png"), + //Fields + //Emojis + Locked: opt.Something(false), + Bot: opt.Something(false), + Group: opt.Something(false), + Discoverable: nul.Something(true), + CreatedAt: opt.Something("2023-09-27T22:06:19Z"), + LastStatusAt: nul.Null[string](), + StatusesCount: opt.Something(jsonint.Int64(123)), + FollowersCount: opt.Something(jsonint.Int64(24789)), + FollowingCount: opt.Something(jsonint.Int64(355)), + //Roles + //MuteExpiresAt + }, + + Expected: `{`+ + `"id":"2737523"`+ + `,`+ + `"username":"janedoe"`+ + `,`+ + `"acct":"janedoe@something.example"`+ + `,`+ + `"url":"https://something.example/@janedoe"`+ + `,`+ + `"uri":"https://something.example/~janedoe"`+ + `,`+ + `"display_name":"Jane Doe \u0026lt;3"`+ + `,`+ + `"note":"\u003cp\u003eHello world!\u003c/p\u003e"`+ + `,`+ + `"avatar":"https://files.example.com/avatar/janedoe.png"`+ + `,`+ + `"avatar_static":"https://files.example.com/avatar-static/janedoe.png"`+ + `,`+ + `"header":"https://files.example.com/header/janedoe.png"`+ + `,`+ + `"header_static":"https://files.example.com/header-static/janedoe.png"`+ + `,`+ + `"fields":[]`+ + `,`+ + `"emojis":[]`+ + `,`+ + `"locked":false`+ + `,`+ + `"bot":false`+ + `,`+ + `"group":false`+ + `,`+ + `"discoverable":true`+ + `,`+ + `"created_at":"2023-09-27T22:06:19Z"`+ + `,`+ + `"last_status_at":null`+ + `,`+ + `"statuses_count":123`+ + `,`+ + `"followers_count":24789`+ + `,`+ + `"following_count":355`+ + `}`, + }, + + + + + + + + + + { + Account: ent.Account{ + ID: opt.Something("47"), + 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("Hello world!
"), + 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 + //Emojis + Locked: opt.Something(false), + Bot: opt.Something(false), + Group: opt.Something(false), + Discoverable: nul.Null[bool](), + CreatedAt: opt.Something("2022-08-16T11:05:08Z"), + LastStatusAt: nul.Something("2023-09-27T22:06:19Z"), + StatusesCount: opt.Something(jsonint.Int64(123)), + FollowersCount: opt.Something(jsonint.Int64(24789)), + FollowingCount: opt.Something(jsonint.Int64(355)), + //Roles + //MuteExpiresAt + }, + + Expected: `{`+ + `"id":"47"`+ + `,`+ + `"username":"joeblow"`+ + `,`+ + `"acct":"joeblow@example.com"`+ + `,`+ + `"url":"https://example.com/@joeblow"`+ + `,`+ + `"uri":"https://example.com/users/joeblow"`+ + `,`+ + `"display_name":"Joe Blow :-)"`+ + `,`+ + `"note":"\u003cp\u003eHello world!\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":null`+ + `,`+ + `"created_at":"2022-08-16T11:05:08Z"`+ + `,`+ + `"last_status_at":"2023-09-27T22:06:19Z"`+ + `,`+ + `"statuses_count":123`+ + `,`+ + `"followers_count":24789`+ + `,`+ + `"following_count":355`+ + `}`, + }, + + + + + + + + + + { + Account: ent.Account{ + ID: opt.Something("47"), + 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("Hello world!
"), + 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: nil, + //Emojis + Locked: opt.Something(false), + Bot: opt.Something(false), + Group: opt.Something(false), + Discoverable: nul.Null[bool](), + CreatedAt: opt.Something("2023-09-27T22:06:19Z"), + LastStatusAt: nul.Null[string](), + StatusesCount: opt.Something(jsonint.Int64(123)), + FollowersCount: opt.Something(jsonint.Int64(24789)), + FollowingCount: opt.Something(jsonint.Int64(355)), + //Roles + //MuteExpiresAt + }, + + Expected: `{`+ + `"id":"47"`+ + `,`+ + `"username":"joeblow"`+ + `,`+ + `"acct":"joeblow@example.com"`+ + `,`+ + `"url":"https://example.com/@joeblow"`+ + `,`+ + `"uri":"https://example.com/users/joeblow"`+ + `,`+ + `"display_name":"Joe Blow :-)"`+ + `,`+ + `"note":"\u003cp\u003eHello world!\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":null`+ + `,`+ + `"created_at":"2023-09-27T22:06:19Z"`+ + `,`+ + `"last_status_at":null`+ + `,`+ + `"statuses_count":123`+ + `,`+ + `"followers_count":24789`+ + `,`+ + `"following_count":355`+ + `}`, + }, + + + + { + Account: ent.Account{ + ID: opt.Something("47"), + 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("Hello world!
"), + 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: []ent.Field{}, + //Emojis + Locked: opt.Something(false), + Bot: opt.Something(false), + Group: opt.Something(false), + Discoverable: nul.Null[bool](), + CreatedAt: opt.Something("2023-09-27T22:06:19Z"), + LastStatusAt: nul.Null[string](), + StatusesCount: opt.Something(jsonint.Int64(123)), + FollowersCount: opt.Something(jsonint.Int64(24789)), + FollowingCount: opt.Something(jsonint.Int64(355)), + //Roles + //MuteExpiresAt + }, + + Expected: `{`+ + `"id":"47"`+ + `,`+ + `"username":"joeblow"`+ + `,`+ + `"acct":"joeblow@example.com"`+ + `,`+ + `"url":"https://example.com/@joeblow"`+ + `,`+ + `"uri":"https://example.com/users/joeblow"`+ + `,`+ + `"display_name":"Joe Blow :-)"`+ + `,`+ + `"note":"\u003cp\u003eHello world!\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":null`+ + `,`+ + `"created_at":"2023-09-27T22:06:19Z"`+ + `,`+ + `"last_status_at":null`+ + `,`+ + `"statuses_count":123`+ + `,`+ + `"followers_count":24789`+ + `,`+ + `"following_count":355`+ + `}`, + }, + + + + { + Account: ent.Account{ + ID: opt.Something("47"), + 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("Hello world!
"), + 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: []ent.Field{ + ent.Field{ + Name: opt.Something("alt"), + Value: opt.Something("@joeblow@greatape.social"), + }, + }, + //Emojis + Locked: opt.Something(false), + Bot: opt.Something(false), + Group: opt.Something(false), + Discoverable: nul.Null[bool](), + CreatedAt: opt.Something("2023-09-27T22:06:19Z"), + LastStatusAt: nul.Null[string](), + StatusesCount: opt.Something(jsonint.Int64(123)), + FollowersCount: opt.Something(jsonint.Int64(24789)), + FollowingCount: opt.Something(jsonint.Int64(355)), + //Roles + //MuteExpiresAt + }, + + Expected: `{`+ + `"id":"47"`+ + `,`+ + `"username":"joeblow"`+ + `,`+ + `"acct":"joeblow@example.com"`+ + `,`+ + `"url":"https://example.com/@joeblow"`+ + `,`+ + `"uri":"https://example.com/users/joeblow"`+ + `,`+ + `"display_name":"Joe Blow :-)"`+ + `,`+ + `"note":"\u003cp\u003eHello world!\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":[`+ + `{`+ + `"name":"alt"`+ + `,`+ + `"value":"@joeblow@greatape.social"`+ + `,`+ + `"verified_at":null`+ + `}`+ + `]`+ + `,`+ + `"emojis":[]`+ + `,`+ + `"locked":false`+ + `,`+ + `"bot":false`+ + `,`+ + `"group":false`+ + `,`+ + `"discoverable":null`+ + `,`+ + `"created_at":"2023-09-27T22:06:19Z"`+ + `,`+ + `"last_status_at":null`+ + `,`+ + `"statuses_count":123`+ + `,`+ + `"followers_count":24789`+ + `,`+ + `"following_count":355`+ + `}`, + }, + + + + { + Account: ent.Account{ + ID: opt.Something("47"), + 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("Hello world!
"), + 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: []ent.Field{ + ent.Field{ + Name: opt.Something("alt"), + Value: opt.Something("@joeblow@greatape.social"), + }, + ent.Field{ + Name: opt.Something("alt (long-form)"), + Value: opt.Something("@joeblow@postfreely.social"), + VerifiedAt: nul.Something("2022-09-29T08:41:46Z"), + }, + }, + //Emojis + Locked: opt.Something(false), + Bot: opt.Something(false), + Group: opt.Something(false), + Discoverable: nul.Null[bool](), + CreatedAt: opt.Something("2023-09-27T22:06:19Z"), + LastStatusAt: nul.Null[string](), + StatusesCount: opt.Something(jsonint.Int64(123)), + FollowersCount: opt.Something(jsonint.Int64(24789)), + FollowingCount: opt.Something(jsonint.Int64(355)), + //Roles + //MuteExpiresAt + }, + + Expected: `{`+ + `"id":"47"`+ + `,`+ + `"username":"joeblow"`+ + `,`+ + `"acct":"joeblow@example.com"`+ + `,`+ + `"url":"https://example.com/@joeblow"`+ + `,`+ + `"uri":"https://example.com/users/joeblow"`+ + `,`+ + `"display_name":"Joe Blow :-)"`+ + `,`+ + `"note":"\u003cp\u003eHello world!\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":[`+ + `{`+ + `"name":"alt"`+ + `,`+ + `"value":"@joeblow@greatape.social"`+ + `,`+ + `"verified_at":null`+ + `}`+ + `,`+ + `{`+ + `"name":"alt (long-form)"`+ + `,`+ + `"value":"@joeblow@postfreely.social"`+ + `,`+ + `"verified_at":"2022-09-29T08:41:46Z"`+ + `}`+ + `]`+ + `,`+ + `"emojis":[]`+ + `,`+ + `"locked":false`+ + `,`+ + `"bot":false`+ + `,`+ + `"group":false`+ + `,`+ + `"discoverable":null`+ + `,`+ + `"created_at":"2023-09-27T22:06:19Z"`+ + `,`+ + `"last_status_at":null`+ + `,`+ + `"statuses_count":123`+ + `,`+ + `"followers_count":24789`+ + `,`+ + `"following_count":355`+ + `}`, + }, + + + + + + + + + + { + Account: ent.Account{ + ID: opt.Something("47"), + 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("Hello world!
"), + 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 + Emojis: nil, + Locked: opt.Something(false), + Bot: opt.Something(false), + Group: opt.Something(false), + Discoverable: nul.Null[bool](), + CreatedAt: opt.Something("2023-09-27T22:06:19Z"), + LastStatusAt: nul.Null[string](), + StatusesCount: opt.Something(jsonint.Int64(123)), + FollowersCount: opt.Something(jsonint.Int64(24789)), + FollowingCount: opt.Something(jsonint.Int64(355)), + //Roles + //MuteExpiresAt + }, + + Expected: `{`+ + `"id":"47"`+ + `,`+ + `"username":"joeblow"`+ + `,`+ + `"acct":"joeblow@example.com"`+ + `,`+ + `"url":"https://example.com/@joeblow"`+ + `,`+ + `"uri":"https://example.com/users/joeblow"`+ + `,`+ + `"display_name":"Joe Blow :-)"`+ + `,`+ + `"note":"\u003cp\u003eHello world!\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":null`+ + `,`+ + `"created_at":"2023-09-27T22:06:19Z"`+ + `,`+ + `"last_status_at":null`+ + `,`+ + `"statuses_count":123`+ + `,`+ + `"followers_count":24789`+ + `,`+ + `"following_count":355`+ + `}`, + }, + + + + { + Account: ent.Account{ + ID: opt.Something("47"), + 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("Hello world!
"), + 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 + Emojis: []ent.CustomEmoji{}, + Locked: opt.Something(false), + Bot: opt.Something(false), + Group: opt.Something(false), + Discoverable: nul.Null[bool](), + CreatedAt: opt.Something("2023-09-27T22:06:19Z"), + LastStatusAt: nul.Null[string](), + StatusesCount: opt.Something(jsonint.Int64(123)), + FollowersCount: opt.Something(jsonint.Int64(24789)), + FollowingCount: opt.Something(jsonint.Int64(355)), + //Roles + //MuteExpiresAt + }, + + Expected: `{`+ + `"id":"47"`+ + `,`+ + `"username":"joeblow"`+ + `,`+ + `"acct":"joeblow@example.com"`+ + `,`+ + `"url":"https://example.com/@joeblow"`+ + `,`+ + `"uri":"https://example.com/users/joeblow"`+ + `,`+ + `"display_name":"Joe Blow :-)"`+ + `,`+ + `"note":"\u003cp\u003eHello world!\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":null`+ + `,`+ + `"created_at":"2023-09-27T22:06:19Z"`+ + `,`+ + `"last_status_at":null`+ + `,`+ + `"statuses_count":123`+ + `,`+ + `"followers_count":24789`+ + `,`+ + `"following_count":355`+ + `}`, + }, + + + + { + Account: ent.Account{ + ID: opt.Something("47"), + 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("Hello world!
"), + 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 + Emojis: []ent.CustomEmoji{ + ent.CustomEmoji{ + ShortCode: opt.Something("batman"), + URL: opt.Something("https://files.example.com/emoji/batman.png"), + StaticURL: opt.Something("https://files.example.com/emoji-static/batman.png"), + VisibleInPicker: opt.Something(true), + }, + }, + Locked: opt.Something(false), + Bot: opt.Something(false), + Group: opt.Something(false), + Discoverable: nul.Null[bool](), + CreatedAt: opt.Something("2023-09-27T22:06:19Z"), + LastStatusAt: nul.Null[string](), + StatusesCount: opt.Something(jsonint.Int64(123)), + FollowersCount: opt.Something(jsonint.Int64(24789)), + FollowingCount: opt.Something(jsonint.Int64(355)), + //Roles + //MuteExpiresAt + }, + + Expected: `{`+ + `"id":"47"`+ + `,`+ + `"username":"joeblow"`+ + `,`+ + `"acct":"joeblow@example.com"`+ + `,`+ + `"url":"https://example.com/@joeblow"`+ + `,`+ + `"uri":"https://example.com/users/joeblow"`+ + `,`+ + `"display_name":"Joe Blow :-)"`+ + `,`+ + `"note":"\u003cp\u003eHello world!\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":[`+ + `{`+ + `"shortcode":"batman"`+ + `,`+ + `"url":"https://files.example.com/emoji/batman.png"`+ + `,`+ + `"static_url":"https://files.example.com/emoji-static/batman.png"`+ + `,`+ + `"visible_in_picker":true`+ + `}`+ + `]`+ + `,`+ + `"locked":false`+ + `,`+ + `"bot":false`+ + `,`+ + `"group":false`+ + `,`+ + `"discoverable":null`+ + `,`+ + `"created_at":"2023-09-27T22:06:19Z"`+ + `,`+ + `"last_status_at":null`+ + `,`+ + `"statuses_count":123`+ + `,`+ + `"followers_count":24789`+ + `,`+ + `"following_count":355`+ + `}`, + }, + + + + { + Account: ent.Account{ + ID: opt.Something("47"), + 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("Hello world!
"), + 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 + Emojis: []ent.CustomEmoji{ + ent.CustomEmoji{ + ShortCode: opt.Something("batman"), + URL: opt.Something("https://files.example.com/emoji/batman.png"), + StaticURL: opt.Something("https://files.example.com/emoji-static/batman.png"), + VisibleInPicker: opt.Something(true), + }, + ent.CustomEmoji{ + ShortCode: opt.Something("joker"), + URL: opt.Something("https://files.example.com/emoji/joker.png"), + StaticURL: opt.Something("https://files.example.com/emoji-static/joker.png"), + VisibleInPicker: opt.Something(false), + }, + }, + Locked: opt.Something(false), + Bot: opt.Something(false), + Group: opt.Something(false), + Discoverable: nul.Null[bool](), + CreatedAt: opt.Something("2023-09-27T22:06:19Z"), + LastStatusAt: nul.Null[string](), + StatusesCount: opt.Something(jsonint.Int64(123)), + FollowersCount: opt.Something(jsonint.Int64(24789)), + FollowingCount: opt.Something(jsonint.Int64(355)), + //Roles + //MuteExpiresAt + }, + + Expected: `{`+ + `"id":"47"`+ + `,`+ + `"username":"joeblow"`+ + `,`+ + `"acct":"joeblow@example.com"`+ + `,`+ + `"url":"https://example.com/@joeblow"`+ + `,`+ + `"uri":"https://example.com/users/joeblow"`+ + `,`+ + `"display_name":"Joe Blow :-)"`+ + `,`+ + `"note":"\u003cp\u003eHello world!\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":[`+ + `{`+ + `"shortcode":"batman"`+ + `,`+ + `"url":"https://files.example.com/emoji/batman.png"`+ + `,`+ + `"static_url":"https://files.example.com/emoji-static/batman.png"`+ + `,`+ + `"visible_in_picker":true`+ + `}`+ + `,`+ + `{`+ + `"shortcode":"joker"`+ + `,`+ + `"url":"https://files.example.com/emoji/joker.png"`+ + `,`+ + `"static_url":"https://files.example.com/emoji-static/joker.png"`+ + `,`+ + `"visible_in_picker":false`+ + `}`+ + `]`+ + `,`+ + `"locked":false`+ + `,`+ + `"bot":false`+ + `,`+ + `"group":false`+ + `,`+ + `"discoverable":null`+ + `,`+ + `"created_at":"2023-09-27T22:06:19Z"`+ + `,`+ + `"last_status_at":null`+ + `,`+ + `"statuses_count":123`+ + `,`+ + `"followers_count":24789`+ + `,`+ + `"following_count":355`+ + `}`, + }, + + + + { + Account: ent.Account{ + ID: opt.Something("47"), + 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("Hello world!
"), + 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 + Emojis: []ent.CustomEmoji{ + ent.CustomEmoji{ + ShortCode: opt.Something("batman"), + URL: opt.Something("https://files.example.com/emoji/batman.png"), + StaticURL: opt.Something("https://files.example.com/emoji-static/batman.png"), + VisibleInPicker: opt.Something(true), + }, + ent.CustomEmoji{ + ShortCode: opt.Something("joker"), + URL: opt.Something("https://files.example.com/emoji/joker.png"), + StaticURL: opt.Something("https://files.example.com/emoji-static/joker.png"), + VisibleInPicker: opt.Something(false), + }, + ent.CustomEmoji{ + ShortCode: opt.Something("spider-man"), + URL: opt.Something("https://files.example.com/emoji/spider-man.png"), + StaticURL: opt.Something("https://files.example.com/emoji-static/spider-man.png"), + VisibleInPicker: opt.Something(true), + Category: opt.Something("spiders"), + }, + }, + Locked: opt.Something(false), + Bot: opt.Something(false), + Group: opt.Something(false), + Discoverable: nul.Null[bool](), + CreatedAt: opt.Something("2023-09-27T22:06:19Z"), + LastStatusAt: nul.Null[string](), + StatusesCount: opt.Something(jsonint.Int64(123)), + FollowersCount: opt.Something(jsonint.Int64(24789)), + FollowingCount: opt.Something(jsonint.Int64(355)), + //Roles + //MuteExpiresAt + }, + + Expected: `{`+ + `"id":"47"`+ + `,`+ + `"username":"joeblow"`+ + `,`+ + `"acct":"joeblow@example.com"`+ + `,`+ + `"url":"https://example.com/@joeblow"`+ + `,`+ + `"uri":"https://example.com/users/joeblow"`+ + `,`+ + `"display_name":"Joe Blow :-)"`+ + `,`+ + `"note":"\u003cp\u003eHello world!\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":[`+ + `{`+ + `"shortcode":"batman"`+ + `,`+ + `"url":"https://files.example.com/emoji/batman.png"`+ + `,`+ + `"static_url":"https://files.example.com/emoji-static/batman.png"`+ + `,`+ + `"visible_in_picker":true`+ + `}`+ + `,`+ + `{`+ + `"shortcode":"joker"`+ + `,`+ + `"url":"https://files.example.com/emoji/joker.png"`+ + `,`+ + `"static_url":"https://files.example.com/emoji-static/joker.png"`+ + `,`+ + `"visible_in_picker":false`+ + `}`+ + `,`+ + `{`+ + `"shortcode":"spider-man"`+ + `,`+ + `"url":"https://files.example.com/emoji/spider-man.png"`+ + `,`+ + `"static_url":"https://files.example.com/emoji-static/spider-man.png"`+ + `,`+ + `"visible_in_picker":true`+ + `,`+ + `"category":"spiders"`+ + `}`+ + `]`+ + `,`+ + `"locked":false`+ + `,`+ + `"bot":false`+ + `,`+ + `"group":false`+ + `,`+ + `"discoverable":null`+ + `,`+ + `"created_at":"2023-09-27T22:06:19Z"`+ + `,`+ + `"last_status_at":null`+ + `,`+ + `"statuses_count":123`+ + `,`+ + `"followers_count":24789`+ + `,`+ + `"following_count":355`+ + `}`, + }, + + + + + + + + + + { + Account: ent.Account{ + ID: opt.Something("47"), + 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("Hello world!
"), + 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 + //Emojis + Locked: opt.Something(false), + Bot: opt.Something(false), + Group: opt.Something(false), + Discoverable: nul.Null[bool](), + CreatedAt: opt.Something("2023-09-27T22:06:19Z"), + LastStatusAt: nul.Null[string](), + StatusesCount: opt.Something(jsonint.Int64(123)), + FollowersCount: opt.Something(jsonint.Int64(24789)), + FollowingCount: opt.Something(jsonint.Int64(355)), + Roles: nil, + //MuteExpiresAt + }, + + Expected: `{`+ + `"id":"47"`+ + `,`+ + `"username":"joeblow"`+ + `,`+ + `"acct":"joeblow@example.com"`+ + `,`+ + `"url":"https://example.com/@joeblow"`+ + `,`+ + `"uri":"https://example.com/users/joeblow"`+ + `,`+ + `"display_name":"Joe Blow :-)"`+ + `,`+ + `"note":"\u003cp\u003eHello world!\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":null`+ + `,`+ + `"created_at":"2023-09-27T22:06:19Z"`+ + `,`+ + `"last_status_at":null`+ + `,`+ + `"statuses_count":123`+ + `,`+ + `"followers_count":24789`+ + `,`+ + `"following_count":355`+ + `}`, + }, + + + + { + Account: ent.Account{ + ID: opt.Something("47"), + 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("Hello world!
"), + 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 + //Emojis + Locked: opt.Something(false), + Bot: opt.Something(false), + Group: opt.Something(false), + Discoverable: nul.Null[bool](), + CreatedAt: opt.Something("2023-09-27T22:06:19Z"), + LastStatusAt: nul.Null[string](), + StatusesCount: opt.Something(jsonint.Int64(123)), + FollowersCount: opt.Something(jsonint.Int64(24789)), + FollowingCount: opt.Something(jsonint.Int64(355)), + Roles: []ent.Role{}, + //MuteExpiresAt + }, + + Expected: `{`+ + `"id":"47"`+ + `,`+ + `"username":"joeblow"`+ + `,`+ + `"acct":"joeblow@example.com"`+ + `,`+ + `"url":"https://example.com/@joeblow"`+ + `,`+ + `"uri":"https://example.com/users/joeblow"`+ + `,`+ + `"display_name":"Joe Blow :-)"`+ + `,`+ + `"note":"\u003cp\u003eHello world!\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":null`+ + `,`+ + `"created_at":"2023-09-27T22:06:19Z"`+ + `,`+ + `"last_status_at":null`+ + `,`+ + `"statuses_count":123`+ + `,`+ + `"followers_count":24789`+ + `,`+ + `"following_count":355`+ + `,`+ + `"roles":[]`+ + `}`, + }, + + + + { + Account: ent.Account{ + ID: opt.Something("47"), + 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("Hello world!
"), + 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 + //Emojis + Locked: opt.Something(false), + Bot: opt.Something(false), + Group: opt.Something(false), + Discoverable: nul.Null[bool](), + CreatedAt: opt.Something("2023-09-27T22:06:19Z"), + LastStatusAt: nul.Null[string](), + StatusesCount: opt.Something(jsonint.Int64(123)), + FollowersCount: opt.Something(jsonint.Int64(24789)), + FollowingCount: opt.Something(jsonint.Int64(355)), + Roles: []ent.Role{ + ent.Role{ + ID: opt.Something(jsonint.Int64(15)), + Name: opt.Something("sponsor (PostFreely)"), + Color: opt.Something("#ff2400"), + Permissions: opt.Something(jsonint.Int64(0)), + Highlighted: opt.Something(true), + }, + }, + //MuteExpiresAt + }, + + Expected: `{`+ + `"id":"47"`+ + `,`+ + `"username":"joeblow"`+ + `,`+ + `"acct":"joeblow@example.com"`+ + `,`+ + `"url":"https://example.com/@joeblow"`+ + `,`+ + `"uri":"https://example.com/users/joeblow"`+ + `,`+ + `"display_name":"Joe Blow :-)"`+ + `,`+ + `"note":"\u003cp\u003eHello world!\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":null`+ + `,`+ + `"created_at":"2023-09-27T22:06:19Z"`+ + `,`+ + `"last_status_at":null`+ + `,`+ + `"statuses_count":123`+ + `,`+ + `"followers_count":24789`+ + `,`+ + `"following_count":355`+ + `,`+ + `"roles":[`+ + `{`+ + `"id":15`+ + `,`+ + `"name":"sponsor (PostFreely)"`+ + `,`+ + `"color":"#ff2400"`+ + `,`+ + `"permissions":0`+ + `,`+ + `"highlighted":true`+ + `}`+ + `]`+ + `}`, + }, + + + + { + Account: ent.Account{ + ID: opt.Something("47"), + 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("Hello world!
"), + 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 + //Emojis + Locked: opt.Something(false), + Bot: opt.Something(false), + Group: opt.Something(false), + Discoverable: nul.Null[bool](), + CreatedAt: opt.Something("2023-09-27T22:06:19Z"), + LastStatusAt: nul.Null[string](), + StatusesCount: opt.Something(jsonint.Int64(123)), + FollowersCount: opt.Something(jsonint.Int64(24789)), + FollowingCount: opt.Something(jsonint.Int64(355)), + Roles: []ent.Role{ + ent.Role{ + ID: opt.Something(jsonint.Int64(15)), + Name: opt.Something("sponsor (PostFreely)"), + Color: opt.Something("#ff2400"), + Permissions: opt.Something(jsonint.Int64(0)), + Highlighted: opt.Something(true), + }, + ent.Role{ + ID: opt.Something(jsonint.Int64(28)), + Name: opt.Something("sponsor (Firefish)"), + Color: opt.Something("#30ff11"), + Permissions: opt.Something(jsonint.Int64(255)), + Highlighted: opt.Something(false), + }, + }, + //MuteExpiresAt + }, + + Expected: `{`+ + `"id":"47"`+ + `,`+ + `"username":"joeblow"`+ + `,`+ + `"acct":"joeblow@example.com"`+ + `,`+ + `"url":"https://example.com/@joeblow"`+ + `,`+ + `"uri":"https://example.com/users/joeblow"`+ + `,`+ + `"display_name":"Joe Blow :-)"`+ + `,`+ + `"note":"\u003cp\u003eHello world!\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":null`+ + `,`+ + `"created_at":"2023-09-27T22:06:19Z"`+ + `,`+ + `"last_status_at":null`+ + `,`+ + `"statuses_count":123`+ + `,`+ + `"followers_count":24789`+ + `,`+ + `"following_count":355`+ + `,`+ + `"roles":[`+ + `{`+ + `"id":15`+ + `,`+ + `"name":"sponsor (PostFreely)"`+ + `,`+ + `"color":"#ff2400"`+ + `,`+ + `"permissions":0`+ + `,`+ + `"highlighted":true`+ + `}`+ + `,`+ + `{`+ + `"id":28`+ + `,`+ + `"name":"sponsor (Firefish)"`+ + `,`+ + `"color":"#30ff11"`+ + `,`+ + `"permissions":255`+ + `,`+ + `"highlighted":false`+ + `}`+ + `]`+ + `}`, + }, + + + + { + Account: ent.Account{ + ID: opt.Something("47"), + 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("Hello world!
"), + 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 + //Emojis + Locked: opt.Something(false), + Bot: opt.Something(false), + Group: opt.Something(false), + Discoverable: nul.Null[bool](), + CreatedAt: opt.Something("2023-09-27T22:06:19Z"), + LastStatusAt: nul.Null[string](), + StatusesCount: opt.Something(jsonint.Int64(123)), + FollowersCount: opt.Something(jsonint.Int64(24789)), + FollowingCount: opt.Something(jsonint.Int64(355)), + Roles: []ent.Role{ + ent.Role{ + ID: opt.Something(jsonint.Int64(15)), + Name: opt.Something("sponsor (PostFreely)"), + Color: opt.Something("#ff2400"), + Permissions: opt.Something(jsonint.Int64(0)), + Highlighted: opt.Something(true), + }, + ent.Role{ + ID: opt.Something(jsonint.Int64(28)), + Name: opt.Something("sponsor (Firefish)"), + Color: opt.Something("#30ff11"), + Permissions: opt.Something(jsonint.Int64(255)), + Highlighted: opt.Something(false), + }, + ent.Role{ + ID: opt.Something(jsonint.Int64(1)), + Name: opt.Something("admin"), + Permissions: opt.Something(jsonint.Int64(4294967295)), + Highlighted: opt.Something(false), + }, + }, + //MuteExpiresAt + }, + + Expected: `{`+ + `"id":"47"`+ + `,`+ + `"username":"joeblow"`+ + `,`+ + `"acct":"joeblow@example.com"`+ + `,`+ + `"url":"https://example.com/@joeblow"`+ + `,`+ + `"uri":"https://example.com/users/joeblow"`+ + `,`+ + `"display_name":"Joe Blow :-)"`+ + `,`+ + `"note":"\u003cp\u003eHello world!\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":null`+ + `,`+ + `"created_at":"2023-09-27T22:06:19Z"`+ + `,`+ + `"last_status_at":null`+ + `,`+ + `"statuses_count":123`+ + `,`+ + `"followers_count":24789`+ + `,`+ + `"following_count":355`+ + `,`+ + `"roles":[`+ + `{`+ + `"id":15`+ + `,`+ + `"name":"sponsor (PostFreely)"`+ + `,`+ + `"color":"#ff2400"`+ + `,`+ + `"permissions":0`+ + `,`+ + `"highlighted":true`+ + `}`+ + `,`+ + `{`+ + `"id":28`+ + `,`+ + `"name":"sponsor (Firefish)"`+ + `,`+ + `"color":"#30ff11"`+ + `,`+ + `"permissions":255`+ + `,`+ + `"highlighted":false`+ + `}`+ + `,`+ + `{`+ + `"id":1`+ + `,`+ + `"name":"admin"`+ + `,`+ + `"color":""`+ + `,`+ + `"permissions":4294967295`+ + `,`+ + `"highlighted":false`+ + `}`+ + `]`+ + `}`, + }, + + + + + + + + + + { + Account: ent.Account{ + ID: opt.Something("47"), + 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("Hello world!
"), + 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 + //Emojis + Locked: opt.Something(false), + Bot: opt.Something(false), + Group: opt.Something(false), + Discoverable: nul.Null[bool](), + CreatedAt: opt.Something("2023-09-27T22:06:19Z"), + LastStatusAt: nul.Null[string](), + StatusesCount: opt.Something(jsonint.Int64(123)), + FollowersCount: opt.Something(jsonint.Int64(24789)), + FollowingCount: opt.Something(jsonint.Int64(355)), + //Roles + MuteExpiresAt: nul.Null[string](), + }, + + Expected: `{`+ + `"id":"47"`+ + `,`+ + `"username":"joeblow"`+ + `,`+ + `"acct":"joeblow@example.com"`+ + `,`+ + `"url":"https://example.com/@joeblow"`+ + `,`+ + `"uri":"https://example.com/users/joeblow"`+ + `,`+ + `"display_name":"Joe Blow :-)"`+ + `,`+ + `"note":"\u003cp\u003eHello world!\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":null`+ + `,`+ + `"created_at":"2023-09-27T22:06:19Z"`+ + `,`+ + `"last_status_at":null`+ + `,`+ + `"statuses_count":123`+ + `,`+ + `"followers_count":24789`+ + `,`+ + `"following_count":355`+ + `,`+ + `"mute_expires_at":null`+ + `}`, + }, + + + + { + Account: ent.Account{ + ID: opt.Something("47"), + 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("Hello world!
"), + 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 + //Emojis + Locked: opt.Something(false), + Bot: opt.Something(false), + Group: opt.Something(false), + Discoverable: nul.Null[bool](), + CreatedAt: opt.Something("2023-09-27T22:06:19Z"), + LastStatusAt: nul.Null[string](), + StatusesCount: opt.Something(jsonint.Int64(123)), + FollowersCount: opt.Something(jsonint.Int64(24789)), + FollowingCount: opt.Something(jsonint.Int64(355)), + //Roles + MuteExpiresAt: nul.Something("2025-11-12T09:10:11Z"), + }, + + Expected: `{`+ + `"id":"47"`+ + `,`+ + `"username":"joeblow"`+ + `,`+ + `"acct":"joeblow@example.com"`+ + `,`+ + `"url":"https://example.com/@joeblow"`+ + `,`+ + `"uri":"https://example.com/users/joeblow"`+ + `,`+ + `"display_name":"Joe Blow :-)"`+ + `,`+ + `"note":"\u003cp\u003eHello world!\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":null`+ + `,`+ + `"created_at":"2023-09-27T22:06:19Z"`+ + `,`+ + `"last_status_at":null`+ + `,`+ + `"statuses_count":123`+ + `,`+ + `"followers_count":24789`+ + `,`+ + `"following_count":355`+ + `,`+ + `"mute_expires_at":"2025-11-12T09:10:11Z"`+ + `}`, + }, } for testNumber, test := range tests { diff --git a/ent/customemoji.go b/ent/customemoji.go index 1bf0769..97c845c 100644 --- a/ent/customemoji.go +++ b/ent/customemoji.go @@ -9,13 +9,6 @@ import ( var _ json.Marshaler = CustomEmoji{} -const ( - errCannotMashalCustomEmojiAsJSONNoShortCode = erorr.Error("cannot marshal ent.CustomEmoji to JSON — no ‘shortcode’ set") - errCannotMashalCustomEmojiAsJSONNoURL = erorr.Error("cannot marshal ent.CustomEmoji to JSON — no ‘url’ set") - errCannotMashalCustomEmojiAsJSONNoStaticURL = erorr.Error("cannot marshal ent.CustomEmoji to JSON — no ‘static_url’ set") - errCannotMashalCustomEmojiAsJSONNoVisibleInPicker = erorr.Error("cannot marshal ent.CustomEmoji to JSON — no ‘visible_in_picker’ set") -) - // CustomEmoji represents a Mastodon API "CustomEmoji". // // See: @@ -30,45 +23,69 @@ type CustomEmoji struct { func (receiver CustomEmoji) MarshalJSON() ([]byte, error) { - data := map[string]interface{}{} + var buffer []byte + + buffer = append(buffer, "{"...) { - value, found := receiver.ShortCode.Get() - if !found { - return nil, errCannotMashalCustomEmojiAsJSONNoShortCode + buffer = append(buffer, `"shortcode":`...) + + marshaled, err := json.Marshal(receiver.ShortCode) + if nil != err { + return nil, erorr.Errorf("mstdn/ent: could not marshal ent.CustomEmoji.ShortCode as JSON: %w", err) + } + + buffer = append(buffer, marshaled...) + } + + { + buffer = append(buffer, `,"url":`...) + + marshaled, err := json.Marshal(receiver.URL) + if nil != err { + return nil, erorr.Errorf("mstdn/ent: could not marshal ent.CustomEmoji.URL as JSON: %w", err) + } + + buffer = append(buffer, marshaled...) + } + + { + buffer = append(buffer, `,"static_url":`...) + + marshaled, err := json.Marshal(receiver.StaticURL) + if nil != err { + return nil, erorr.Errorf("mstdn/ent: could not marshal ent.CustomEmoji.StaticURL as JSON: %w", err) + } + + buffer = append(buffer, marshaled...) + } + + { + buffer = append(buffer, `,"visible_in_picker":`...) + + marshaled, err := json.Marshal(receiver.VisibleInPicker) + if nil != err { + return nil, erorr.Errorf("mstdn/ent: could not marshal ent.CustomEmoji.VisibleInPicker as JSON: %w", err) + } + + buffer = append(buffer, marshaled...) + } + + { + if opt.Nothing[string]() != receiver.Category { + + buffer = append(buffer, `,"category":`...) + + marshaled, err := json.Marshal(receiver.Category) + if nil != err { + return nil, erorr.Errorf("mstdn/ent: could not marshal ent.CustomEmoji.Category as JSON: %w", err) + } + + buffer = append(buffer, marshaled...) } - - data["shortcode"] = value - } - { - value, found := receiver.URL.Get() - if !found { - return nil, errCannotMashalCustomEmojiAsJSONNoURL - } - - data["url"] = value - } - { - value, found := receiver.StaticURL.Get() - if !found { - return nil, errCannotMashalCustomEmojiAsJSONNoStaticURL - } - - data["static_url"] = value - } - { - value, found := receiver.VisibleInPicker.Get() - if !found { - return nil, errCannotMashalCustomEmojiAsJSONNoVisibleInPicker - } - - data["visible_in_picker"] = value - } - { - receiver.Category.WhenSomething(func(value string){ - data["category"] = value - }) } - return json.Marshal(data) + buffer = append(buffer, "}"...) + + return buffer, nil } diff --git a/ent/customemoji_marshaljson_test.go b/ent/customemoji_marshaljson_test.go index 231dbc6..3b6ad06 100644 --- a/ent/customemoji_marshaljson_test.go +++ b/ent/customemoji_marshaljson_test.go @@ -25,8 +25,8 @@ func TestCustomEmoji_MarshalJSON(t *testing.T) { Expected: "{" +"\n"+ "\t"+ `"shortcode":` +`""` +"," +"\n"+ - "\t"+ `"static_url":` +`""` +"," +"\n"+ "\t"+ `"url":` +`""` +"," +"\n"+ + "\t"+ `"static_url":` +`""` +"," +"\n"+ "\t"+ `"visible_in_picker":` +`false` +"" +"\n"+ "}" +"\n", }, @@ -43,8 +43,8 @@ func TestCustomEmoji_MarshalJSON(t *testing.T) { Expected: "{" +"\n"+ "\t"+ `"shortcode":` +`"bananas"` +"," +"\n"+ - "\t"+ `"static_url":` +`""` +"," +"\n"+ "\t"+ `"url":` +`""` +"," +"\n"+ + "\t"+ `"static_url":` +`""` +"," +"\n"+ "\t"+ `"visible_in_picker":` +`false` +"" +"\n"+ "}" +"\n", }, @@ -58,8 +58,8 @@ func TestCustomEmoji_MarshalJSON(t *testing.T) { Expected: "{" +"\n"+ "\t"+ `"shortcode":` +`""` +"," +"\n"+ - "\t"+ `"static_url":` +`""` +"," +"\n"+ "\t"+ `"url":` +`"https://example.com/emoji/cracra"` +"," +"\n"+ + "\t"+ `"static_url":` +`""` +"," +"\n"+ "\t"+ `"visible_in_picker":` +`false` +"" +"\n"+ "}" +"\n", }, @@ -73,8 +73,8 @@ func TestCustomEmoji_MarshalJSON(t *testing.T) { Expected: "{" +"\n"+ "\t"+ `"shortcode":` +`""` +"," +"\n"+ - "\t"+ `"static_url":` +`"https://static.example.com/img/emoji/cracra.png"` +"," +"\n"+ "\t"+ `"url":` +`""` +"," +"\n"+ + "\t"+ `"static_url":` +`"https://static.example.com/img/emoji/cracra.png"` +"," +"\n"+ "\t"+ `"visible_in_picker":` +`false` +"" +"\n"+ "}" +"\n", }, @@ -88,8 +88,8 @@ func TestCustomEmoji_MarshalJSON(t *testing.T) { Expected: "{" +"\n"+ "\t"+ `"shortcode":` +`""` +"," +"\n"+ - "\t"+ `"static_url":` +`""` +"," +"\n"+ "\t"+ `"url":` +`""` +"," +"\n"+ + "\t"+ `"static_url":` +`""` +"," +"\n"+ "\t"+ `"visible_in_picker":` +`true` +"" +"\n"+ "}" +"\n", },