Skip to content

Commit

Permalink
Merge pull request #214 from wonderflow/test
Browse files Browse the repository at this point in the history
add more test about periods
  • Loading branch information
hasheddan authored Oct 9, 2020
2 parents 51c117e + 9cfceb9 commit ae2a382
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pkg/fieldpath/fieldpath_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ func TestFieldOrIndex(t *testing.T) {
s: "'coolField'",
want: Segment{Type: SegmentField, Field: "coolField"},
},
"QuotedFieldWithPeriods": {
reason: "A quoted string with periods should be interpreted as a field segment with the quotes removed",
s: "'cool.Field'",
want: Segment{Type: SegmentField, Field: "cool.Field"},
},
"Index": {
reason: "An unambiguous integer should be interpreted as an index segment",
s: "3",
Expand Down Expand Up @@ -212,6 +217,17 @@ func TestParse(t *testing.T) {
},
},
},
"QuotedFieldWithPeriodInBracket": {
reason: "A field name specified using quote and in bracket can include a period",
path: "metadata.labels['app.hash']",
want: want{
s: Segments{
Field("metadata"),
Field("labels"),
FieldOrIndex("app.hash"),
},
},
},
"LeadingPeriod": {
reason: "A path may not start with a period (unlike a JSON path)",
path: ".metadata.name",
Expand Down

0 comments on commit ae2a382

Please sign in to comment.