Unverified Commit 4c4d18a5 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #66111 from fntlnz/fieldpath-tests-improvement

Automatic merge from submit-queue (batch tested with PRs 66011, 66111, 66106, 66039, 65745). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. fieldpath: Add tests for missing cases Tests some missing cases in `pkg/fieldpath`. **Release note**: ```release-note NONE ``` Signed-off-by: 's avatarLorenzo Fontana <lo@linux.com>
parents 0b1f57c7 d645056b
......@@ -108,6 +108,28 @@ func TestExtractFieldPathAsString(t *testing.T) {
expectedValue: "1",
},
{
name: "ok - uid",
fieldPath: "metadata.uid",
obj: &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
UID: "b70b3269-858e-12a8-9cf2-1232a194038a",
},
},
expectedValue: "b70b3269-858e-12a8-9cf2-1232a194038a",
},
{
name: "ok - label",
fieldPath: "metadata.labels['something']",
obj: &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
"something": "label value",
},
},
},
expectedValue: "label value",
},
{
name: "invalid expression",
fieldPath: "metadata.whoops",
obj: &v1.Pod{
......@@ -137,6 +159,12 @@ func TestExtractFieldPathAsString(t *testing.T) {
},
expectedMessageFragment: "invalid key subscript in metadata.labels",
},
{
name: "invalid subscript",
fieldPath: "metadata.notexisting['something']",
obj: &v1.Pod{},
expectedMessageFragment: "fieldPath \"metadata.notexisting['something']\" does not support subscript",
},
}
for _, tc := range cases {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment