♻️ Get rid of PartialEntry

This commit is contained in:
Dan Jones 2024-03-10 15:26:00 -05:00
commit 820a2de269
5 changed files with 111 additions and 57 deletions

View file

@ -9,7 +9,6 @@ import (
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// Type assertions
@ -18,19 +17,6 @@ var _ encoding.TextUnmarshaler = new(Entry)
var _ json.Marshaler = Entry{}
var _ json.Unmarshaler = new(Entry)
func TestPartialEntry(t *testing.T) {
e := PartialEntry()
assert.True(t, e.skipMissing)
err := json.Unmarshal([]byte(`{"a":42}`), &e)
assert.NoError(t, err)
assert.Equal(t, "", e.Title)
assert.Equal(t, time.Time{}, e.Date)
require.Len(t, e.Fields, 1)
f := e.Fields[0]
assert.Equal(t, "a", f.Key)
assert.Equal(t, int64(42), f.Value)
}
func TestEntryMarshal(t *testing.T) {
when := time.Now()
whens := when.Format(DateFormat)
@ -84,7 +70,7 @@ func TestEntryMarshal(t *testing.T) {
func getEntryMarshalTestRunner(title string, date time.Time, fields []Meta, first string, lines []string, err error) func(*testing.T) {
return func(t *testing.T) {
en := Entry{title, date, fields, false}
en := Entry{title, date, fields}
o, er := en.MarshalText()
assert.Equal(t, err, er)
if first == "" {
@ -232,7 +218,7 @@ func TestEntryJsonMarshal(t *testing.T) {
func getEntryJsonMarshalTestRunner(title string, date time.Time, fields []Meta, out string, err error) func(t *testing.T) {
return func(t *testing.T) {
e := Entry{title, date, fields, false}
e := Entry{title, date, fields}
o, er := json.Marshal(e)
if err == nil {
assert.JSONEq(t, out, string(o))