Skip to content
This repository has been archived by the owner on May 25, 2022. It is now read-only.

Commit

Permalink
Add more tests for serialization of field syntax (#350)
Browse files Browse the repository at this point in the history
Field syntax can be used to refer directly to the body of a log,
but the serialization of this case was not well tested. This
change adds additional tests to cover valid cases.
  • Loading branch information
djaglowski authored Jan 20, 2022
1 parent 1cec634 commit 39eda63
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions entry/field_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,14 @@ func TestFieldUnmarshalJSON(t *testing.T) {
NewBodyField("test1", "test2"),
},
{
"RootField",
"BodyShort",
[]byte(`"$"`),
NewBodyField([]string{}...),
NewBodyField(),
},
{
"BodyLong",
[]byte(`"$body"`),
NewBodyField(),
},
}

Expand Down Expand Up @@ -80,6 +85,11 @@ func TestFieldMarshalJSON(t *testing.T) {
NewBodyField("test1", "test2"),
[]byte(`"test1.test2"`),
},
{
"BodyLong",
NewBodyField(),
[]byte(`"$body"`),
},
}

for _, tc := range cases {
Expand Down Expand Up @@ -108,11 +118,6 @@ func TestFieldUnmarshalYAML(t *testing.T) {
[]byte(`test1`),
NewBodyField("test1"),
},
{
"RootField",
[]byte(`"$"`),
NewBodyField([]string{}...),
},
{
"ComplexField",
[]byte(`"test1.test2"`),
Expand All @@ -123,6 +128,16 @@ func TestFieldUnmarshalYAML(t *testing.T) {
[]byte(`"$.test1.test2"`),
NewBodyField("test1", "test2"),
},
{
"BodyShort",
[]byte(`"$"`),
NewBodyField(),
},
{
"BodyLong",
[]byte(`"$body"`),
NewBodyField(),
},
}

for _, tc := range cases {
Expand Down Expand Up @@ -161,7 +176,7 @@ func TestFieldMarshalYAML(t *testing.T) {
"test1.test2\n",
},
{
"EmptyField",
"Body",
NewBodyField(),
"$body\n",
},
Expand Down

0 comments on commit 39eda63

Please sign in to comment.