refactoring

This commit is contained in:
yura 2021-02-26 14:23:06 +03:00
parent c40056101d
commit 1f8626fac2
2 changed files with 7 additions and 6 deletions

View file

@ -3,7 +3,5 @@ package v5
import "encoding/json"
func (t Tag) MarshalJSON() ([]byte, error) {
name, err := json.Marshal(t.Name)
return name, err
return json.Marshal(t.Name)
}

View file

@ -12,10 +12,13 @@ func TestTag_MarshalJSON(t *testing.T) {
{"second", "#ffa654", false},
}
names := []byte(`["first","second"]`)
str, _ := json.Marshal(tags)
str, err := json.Marshal(tags)
eq := reflect.DeepEqual(str, names)
if eq != true {
if err != nil {
t.Errorf("%v", err.Error())
}
if !reflect.DeepEqual(str, names) {
t.Errorf("Marshaled: %#v\nExpected: %#v\n", str, names)
}
}