Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #352 from ecordell/support-v1-crds
Bug 1825512: Support v1 crds in manifests
- Loading branch information
Showing
2 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package resourceread | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestReadCustomResourceDefinitionOrDie(t *testing.T) { | ||
type args struct { | ||
objBytes []byte | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
}{ | ||
{ | ||
name:"v1", | ||
args: args{ | ||
objBytes: []byte(` | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
name: shoulds.parse.com | ||
spec: | ||
group: parse.com | ||
names: | ||
kind: ShouldParse | ||
listKind: ShouldParseList | ||
plural: shoulds | ||
singular: should | ||
scope: Namespaced | ||
versions: | ||
- name: v1alpha1 | ||
schema: | ||
openAPIV3Schema: | ||
description: ShouldParse is a v1 CRD that should be parsed. | ||
type: object | ||
served: true | ||
storage: true | ||
subresources: | ||
status: {} | ||
`), | ||
}, | ||
}, | ||
{ | ||
name:"v1beta1", | ||
args: args{ | ||
objBytes: []byte(` | ||
apiVersion: apiextensions.k8s.io/v1beta1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
name: alreadys.parse.com | ||
spec: | ||
group: parse.com | ||
names: | ||
kind: AlreadyParse | ||
listKind: AlreadyParseList | ||
plural: alreadys | ||
singular: already | ||
scope: Namespaced | ||
versions: | ||
- name: v1alpha1 | ||
schema: | ||
openAPIV3Schema: | ||
description: AlreadyParse is a v1beta1 CRD that should be parsed. | ||
type: object | ||
served: true | ||
storage: true | ||
subresources: | ||
status: {} | ||
`), | ||
}, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
defer func() { | ||
if r := recover(); r != nil { | ||
t.Error(r) | ||
t.Fail() | ||
} | ||
}() | ||
_ = ReadCustomResourceDefinitionOrDie(tt.args.objBytes) | ||
}) | ||
} | ||
} |