MCPcopy Create free account
hub / github.com/devspace-sh/devspace / TestGetParentPath

Function TestGetParentPath

pkg/devspace/config/loader/patch/path_test.go:44–69  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

42}
43
44func TestGetParentPath(t *testing.T) {
45 testCases := map[OpPath]string{
46 "": "",
47 "parent1.child1": "parent1",
48 "parent1['child1']": "parent1",
49 "parent1.parent2.child1": "parent1.parent2",
50 "parent1['parent2']['child1']": "parent1['parent2']",
51 "$.parent1.child1": "$.parent1",
52 "$.*.child1": "$.*",
53 "$.deployments[*].parent1.child1": "$.deployments[*].parent1",
54 "$.deployments[?(@.name=='backend')].parent1.child1": "$.deployments[?(@.name=='backend')].parent1",
55 "$.deployments[?(@.name=~/^backend/)].parent1.child1": "$.deployments[?(@.name=~/^backend/)].parent1",
56 "$.deployments[?(@.name=~/^backend/)].child1": "$.deployments[?(@.name=~/^backend/)]",
57 "$.deployments[?(@.name=~/^Backend/)].child1": "$.deployments[?(@.name=~/^Backend/)]",
58 "$.deployments[?(@.name=~/^backend/)]": "$.deployments",
59 "$.deployments[?(@.name=~/^backend\\//)]": "$.deployments",
60 "$.deployments[*]": "$.deployments",
61 }
62
63 for input, expected := range testCases {
64 actual := input.getParentPath()
65 if expected != actual {
66 t.Errorf("TestCase %s\nactual:%s\nexpected:%s", input, actual, expected)
67 }
68 }
69}
70
71func TestTransformPath(t *testing.T) {
72 testCases := map[string]string{

Callers

nothing calls this directly

Calls 2

getParentPathMethod · 0.80
ErrorfMethod · 0.45

Tested by

no test coverage detected