Skip to content

Commit a75f4cc

Browse files
committed
add failing unit test
Signed-off-by: Tim Ramlot <[email protected]>
1 parent fe06e7e commit a75f4cc

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

paths/path_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,33 @@ func TestParsePath(t *testing.T) {
7373
})
7474
}
7575
}
76+
77+
func TestWithProperty(t *testing.T) {
78+
rootPath := Path{}.WithProperty("foo").WithProperty("bar").WithProperty("aaaa")
79+
80+
path1 := rootPath.WithProperty("baz1")
81+
path2 := rootPath.WithProperty("baz2")
82+
83+
if path1.String() != "foo.bar.aaaa.baz1" {
84+
t.Errorf("path1.String() = %v, expected %v", path1.String(), "foo.bar.aaaa.baz1")
85+
}
86+
87+
if path2.String() != "foo.bar.aaaa.baz2" {
88+
t.Errorf("path2.String() = %v, expected %v", path2.String(), "foo.bar.aaaa.baz2")
89+
}
90+
}
91+
92+
func TestWithIndex(t *testing.T) {
93+
rootPath := Path{}.WithProperty("foo").WithProperty("bar").WithProperty("aaaa")
94+
95+
path1 := rootPath.WithIndex(0)
96+
path2 := rootPath.WithIndex(1)
97+
98+
if path1.String() != "foo.bar.aaaa[0]" {
99+
t.Errorf("path1.String() = %v, expected %v", path1.String(), "foo.bar.aaaa[0]")
100+
}
101+
102+
if path2.String() != "foo.bar.aaaa[1]" {
103+
t.Errorf("path2.String() = %v, expected %v", path2.String(), "foo.bar.aaaa[1]")
104+
}
105+
}

0 commit comments

Comments
 (0)