Skip to content

Commit

Permalink
Add more regression testing and compilation steps
Browse files Browse the repository at this point in the history
  • Loading branch information
rquitales committed Sep 12, 2024
1 parent ae396e8 commit 06dfe8c
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion tests/crds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,29 @@ func TestCRDsFromFile(t *testing.T) {

// TestCRDsFromUrl pulls the CRD YAML file from a URL and generates it in each language
func TestCRDsFromUrl(t *testing.T) {
validateNodeCompiles := func(t *testing.T, path string) {
withDir(t, path, func() {
runRequireNoError(t, exec.Command("npm", "install"))
runRequireNoError(t, exec.Command("npm", "run", "build"))
})
}

validateGolangCompiles := func(t *testing.T, path string) {
withDir(t, path, func() {
runRequireNoError(t, exec.Command("go", "mod", "init", "fakepackage"))
runRequireNoError(t, exec.Command("go", "mod", "tidy"))
runRequireNoError(t, exec.Command("go", "vet", "./..."))
})
}

compileValidationFn := map[string]func(t *testing.T, path string){
"nodejs": validateNodeCompiles,
"go": validateGolangCompiles,
"python": nil,
"java": nil,
"dotnet": nil,
}

tests := []struct {
name string
url string
Expand All @@ -98,6 +121,16 @@ func TestCRDsFromUrl(t *testing.T) {
name: "Contours",
url: "https://raw.githubusercontent.com/projectcontour/contour-operator/f8c07498803d062e30c255976270cbc82cd619b0/config/crd/bases/operator.projectcontour.io_contours.yaml",
},
{
// https://github.com/pulumi/crd2pulumi/issues/141
name: "ElementDeployment",
url: "https://raw.githubusercontent.com/element-hq/ess-starter-edition-core/d7e792bf8a872f06f02f59d807a1c16ee933862b/roles/elementdeployment/files/elementdeployment-schema.yaml",
},
{
// https://github.com/pulumi/crd2pulumi/issues/142
name: "Keycloak",
url: "https://raw.githubusercontent.com/keycloak/keycloak-k8s-resources/25.0.4/kubernetes/keycloaks.k8s.keycloak.org-v1.yml",
},
}

for _, tt := range tests {
Expand All @@ -106,7 +139,7 @@ func TestCRDsFromUrl(t *testing.T) {
lang := lang
t.Run(lang, func(t *testing.T) {
t.Parallel()
execCrd2Pulumi(t, lang, tt.url, nil)
execCrd2Pulumi(t, lang, tt.url, compileValidationFn[lang])
})
}
})
Expand Down

0 comments on commit 06dfe8c

Please sign in to comment.