mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 03:03:59 +00:00
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: Lorenzo Fontana <lo@linux.com>
This commit is contained in:
commit
4c4d18a582
@ -107,6 +107,28 @@ func TestExtractFieldPathAsString(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expectedValue: "1",
|
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",
|
name: "invalid expression",
|
||||||
fieldPath: "metadata.whoops",
|
fieldPath: "metadata.whoops",
|
||||||
@ -137,6 +159,12 @@ func TestExtractFieldPathAsString(t *testing.T) {
|
|||||||
},
|
},
|
||||||
expectedMessageFragment: "invalid key subscript in metadata.labels",
|
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 {
|
for _, tc := range cases {
|
||||||
|
Loading…
Reference in New Issue
Block a user