From 41c553b90ac2709ac6ee1c5977549a61cb9d8d17 Mon Sep 17 00:00:00 2001 From: Charles Iliya Krempeaux Date: Tue, 26 Sep 2023 14:29:10 +0900 Subject: [PATCH] initial commits --- account.go => ent/account.go | 0 customemoji.go => ent/customemoji.go | 10 ++++---- .../customemoji_marshaljson_test.go | 2 +- errors.go => ent/errors.go | 2 +- field.go => ent/field.go | 6 ++--- .../field_marshaljson_test.go | 24 +++++++++---------- .../field_unmarshaljson_test.go | 14 +++++------ role.go => ent/role.go | 2 +- 8 files changed, 30 insertions(+), 30 deletions(-) rename account.go => ent/account.go (100%) rename customemoji.go => ent/customemoji.go (84%) rename customemoji_marshaljson_test.go => ent/customemoji_marshaljson_test.go (99%) rename errors.go => ent/errors.go (88%) rename field.go => ent/field.go (94%) rename field_marshaljson_test.go => ent/field_marshaljson_test.go (86%) rename field_unmarshaljson_test.go => ent/field_unmarshaljson_test.go (74%) rename role.go => ent/role.go (97%) diff --git a/account.go b/ent/account.go similarity index 100% rename from account.go rename to ent/account.go diff --git a/customemoji.go b/ent/customemoji.go similarity index 84% rename from customemoji.go rename to ent/customemoji.go index 4f1b38f..1bf0769 100644 --- a/customemoji.go +++ b/ent/customemoji.go @@ -1,4 +1,4 @@ -package mstdn +package ent import ( "encoding/json" @@ -10,10 +10,10 @@ import ( var _ json.Marshaler = CustomEmoji{} const ( - errCannotMashalCustomEmojiAsJSONNoShortCode = erorr.Error("cannot marshal mstdn.CustomEmoji to JSON — no ‘shortcode’ set") - errCannotMashalCustomEmojiAsJSONNoURL = erorr.Error("cannot marshal mstdn.CustomEmoji to JSON — no ‘url’ set") - errCannotMashalCustomEmojiAsJSONNoStaticURL = erorr.Error("cannot marshal mstdn.CustomEmoji to JSON — no ‘static_url’ set") - errCannotMashalCustomEmojiAsJSONNoVisibleInPicker = erorr.Error("cannot marshal mstdn.CustomEmoji to JSON — no ‘visible_in_picker’ set") + 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". diff --git a/customemoji_marshaljson_test.go b/ent/customemoji_marshaljson_test.go similarity index 99% rename from customemoji_marshaljson_test.go rename to ent/customemoji_marshaljson_test.go index 264c3e2..231dbc6 100644 --- a/customemoji_marshaljson_test.go +++ b/ent/customemoji_marshaljson_test.go @@ -1,4 +1,4 @@ -package mstdn +package ent import ( "testing" diff --git a/errors.go b/ent/errors.go similarity index 88% rename from errors.go rename to ent/errors.go index 74fc99d..6092fe9 100644 --- a/errors.go +++ b/ent/errors.go @@ -1,4 +1,4 @@ -package mstdn +package ent import ( "sourcecode.social/reiver/go-erorr" diff --git a/field.go b/ent/field.go similarity index 94% rename from field.go rename to ent/field.go index 3107cdb..4fe88c1 100644 --- a/field.go +++ b/ent/field.go @@ -1,4 +1,4 @@ -package mstdn +package ent import ( "encoding/json" @@ -12,8 +12,8 @@ var _ json.Marshaler = Field{} var _ json.Unmarshaler = &Field{} const ( - errCannotMashalFieldAsJSONNoName = erorr.Error("cannot marshal mstdn.Field to JSON — no ‘name’ set") - errCannotMashalFieldAsJSONNoValue = erorr.Error("cannot marshal mstdn.Field to JSON — no ‘value’ set") + errCannotMashalFieldAsJSONNoName = erorr.Error("cannot marshal ent.Field to JSON — no ‘name’ set") + errCannotMashalFieldAsJSONNoValue = erorr.Error("cannot marshal ent.Field to JSON — no ‘value’ set") ) // Field represents a Mastodon API "Field". diff --git a/field_marshaljson_test.go b/ent/field_marshaljson_test.go similarity index 86% rename from field_marshaljson_test.go rename to ent/field_marshaljson_test.go index 123469c..90ad094 100644 --- a/field_marshaljson_test.go +++ b/ent/field_marshaljson_test.go @@ -1,4 +1,4 @@ -package mstdn_test +package ent_test import ( "testing" @@ -6,17 +6,17 @@ import ( "bytes" "encoding/json" - "sourcecode.social/reiver/go-mstdn" + "sourcecode.social/reiver/go-mstdn/ent" ) func TestField_MarshalJSON(t *testing.T) { tests := []struct{ - Value mstdn.Field + Value ent.Field Expected string }{ { - Value: mstdn.FieldNameValue("", ""), + Value: ent.FieldNameValue("", ""), Expected: "{" +"\n"+ "\t"+ `"name":` +`""` +"," +"\n"+ @@ -28,7 +28,7 @@ func TestField_MarshalJSON(t *testing.T) { { - Value: mstdn.FieldNameValue("NAME", ""), + Value: ent.FieldNameValue("NAME", ""), Expected: "{" +"\n"+ "\t"+ `"name":` +`"NAME"` +"," +"\n"+ @@ -37,7 +37,7 @@ func TestField_MarshalJSON(t *testing.T) { "}" +"\n", }, { - Value: mstdn.FieldNameValue("", "VALUE"), + Value: ent.FieldNameValue("", "VALUE"), Expected: "{" +"\n"+ "\t"+ `"name":` +`""` +"," +"\n"+ @@ -46,7 +46,7 @@ func TestField_MarshalJSON(t *testing.T) { "}" +"\n", }, { - Value: mstdn.FieldNameValue("NAME", "VALUE"), + Value: ent.FieldNameValue("NAME", "VALUE"), Expected: "{" +"\n"+ "\t"+ `"name":` +`"NAME"` +"," +"\n"+ @@ -58,7 +58,7 @@ func TestField_MarshalJSON(t *testing.T) { { - Value: mstdn.FieldNameValue("age", "47"), + Value: ent.FieldNameValue("age", "47"), Expected: "{" +"\n"+ "\t"+ `"name":` +`"age"` +"," +"\n"+ @@ -70,7 +70,7 @@ func TestField_MarshalJSON(t *testing.T) { { - Value: mstdn.FieldVerifiedNameValue("2023-09-22T22:45:22Z", "NAME", ""), + Value: ent.FieldVerifiedNameValue("2023-09-22T22:45:22Z", "NAME", ""), Expected: "{" +"\n"+ "\t"+ `"name":` +`"NAME"` +"," +"\n"+ @@ -79,7 +79,7 @@ func TestField_MarshalJSON(t *testing.T) { "}" +"\n", }, { - Value: mstdn.FieldVerifiedNameValue("2023-09-22T22:45:22Z", "", "VALUE"), + Value: ent.FieldVerifiedNameValue("2023-09-22T22:45:22Z", "", "VALUE"), Expected: "{" +"\n"+ "\t"+ `"name":` +`""` +"," +"\n"+ @@ -88,7 +88,7 @@ func TestField_MarshalJSON(t *testing.T) { "}" +"\n", }, { - Value: mstdn.FieldVerifiedNameValue("2023-09-22T22:45:22Z", "NAME", "VALUE"), + Value: ent.FieldVerifiedNameValue("2023-09-22T22:45:22Z", "NAME", "VALUE"), Expected: "{" +"\n"+ "\t"+ `"name":` +`"NAME"` +"," +"\n"+ @@ -100,7 +100,7 @@ func TestField_MarshalJSON(t *testing.T) { { - Value: mstdn.FieldVerifiedNameValue("2023-09-22T22:45:22Z", "age", "47"), + Value: ent.FieldVerifiedNameValue("2023-09-22T22:45:22Z", "age", "47"), Expected: "{" +"\n"+ "\t"+ `"name":` +`"age"` +"," +"\n"+ diff --git a/field_unmarshaljson_test.go b/ent/field_unmarshaljson_test.go similarity index 74% rename from field_unmarshaljson_test.go rename to ent/field_unmarshaljson_test.go index 0d30d7a..d1ca6e9 100644 --- a/field_unmarshaljson_test.go +++ b/ent/field_unmarshaljson_test.go @@ -1,36 +1,36 @@ -package mstdn_test +package ent_test import ( "testing" "encoding/json" - "sourcecode.social/reiver/go-mstdn" + "sourcecode.social/reiver/go-mstdn/ent" ) func TestField_UnmarshalJSON(t *testing.T) { tests := []struct{ JSON string - Expected mstdn.Field + Expected ent.Field }{ { JSON: `{"name":"Location","value":"Metro Vancouver"}`, - Expected: mstdn.FieldNameValue("Location", "Metro Vancouver"), + Expected: ent.FieldNameValue("Location", "Metro Vancouver"), }, { JSON: `{"name":"Location","value":"Metro Vancouver", "verified_at":null}`, - Expected: mstdn.FieldNameValue("Location", "Metro Vancouver"), + Expected: ent.FieldNameValue("Location", "Metro Vancouver"), }, { JSON: `{"name":"Location","value":"Metro Vancouver", "verified_at":"2023-09-22T22:45:22Z"}`, - Expected: mstdn.FieldVerifiedNameValue("2023-09-22T22:45:22Z", "Location", "Metro Vancouver"), + Expected: ent.FieldVerifiedNameValue("2023-09-22T22:45:22Z", "Location", "Metro Vancouver"), }, } for testNumber, test := range tests { - var actual mstdn.Field + var actual ent.Field err := json.Unmarshal([]byte(test.JSON), &actual) if nil != err { diff --git a/role.go b/ent/role.go similarity index 97% rename from role.go rename to ent/role.go index 990b7fb..3687dea 100644 --- a/role.go +++ b/ent/role.go @@ -1,4 +1,4 @@ -package mstdn +package ent import ( "sourcecode.social/reiver/go-opt"