mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
Merge pull request #54113 from spzala/groupkindvalidationtest
Automatic merge from submit-queue. 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>. Create new unit tests for version and kind validation This is a follow up PR per discussion in the https://github.com/kubernetes/kubernetes/pull/53587 Creating new unit tests here for basic and aggregated validation of version and kind group. **What this PR does / why we need it**: **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes # **Special notes for your reviewer**: **Release note**: ```release-note NONE ```
This commit is contained in:
commit
d7eebdfdbe
@ -335,4 +335,63 @@ items:
|
||||
|
||||
Expect(err).To(BeNil())
|
||||
})
|
||||
|
||||
It("fails because apiVersion is not provided", func() {
|
||||
err := validator.ValidateBytes([]byte(`
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: name
|
||||
spec:
|
||||
containers:
|
||||
- name: name
|
||||
image: image
|
||||
`))
|
||||
Expect(err.Error()).To(Equal("apiVersion not set"))
|
||||
})
|
||||
|
||||
It("fails because apiVersion type is not string and kind is not provided", func() {
|
||||
err := validator.ValidateBytes([]byte(`
|
||||
apiVersion: 1
|
||||
metadata:
|
||||
name: name
|
||||
spec:
|
||||
containers:
|
||||
- name: name
|
||||
image: image
|
||||
`))
|
||||
Expect(err.Error()).To(Equal("[apiVersion isn't string type, kind not set]"))
|
||||
})
|
||||
|
||||
It("fails because List first item is missing kind and second item is missing apiVersion", func() {
|
||||
err := validator.ValidateBytes([]byte(`
|
||||
apiVersion: v1
|
||||
kind: List
|
||||
items:
|
||||
- apiVersion: v1
|
||||
metadata:
|
||||
name: name
|
||||
spec:
|
||||
replicas: 1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
name: name
|
||||
spec:
|
||||
containers:
|
||||
- name: name
|
||||
image: image
|
||||
- kind: Service
|
||||
metadata:
|
||||
name: name
|
||||
spec:
|
||||
type: NodePort
|
||||
ports:
|
||||
- port: 123
|
||||
targetPort: 1234
|
||||
name: name
|
||||
selector:
|
||||
name: name
|
||||
`))
|
||||
Expect(err.Error()).To(Equal("[kind not set, apiVersion not set]"))
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user