Skip to content

Commit

Permalink
Decouple integretion tests from GOPATH
Browse files Browse the repository at this point in the history
The header file is loaded from the GOPATH
k8s dir by default, which makes it impossible
to develop if you do not have the local
dependencies in your GOPATH.

This commit ensures the header file is
loaded from the project's directory.

It also includes a cleanup of the README.

Signed-off-by: austin ce <austin.cawley@gmail.com>
  • Loading branch information
austince committed Oct 7, 2021
1 parent 6ea5c02 commit 00f4ec9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions test/integration/README.md
Expand Up @@ -19,7 +19,7 @@ on API rule violations.

```bash
$ go run ../../cmd/openapi-gen/openapi-gen.go \
-i "k8s.io/kube-openapi/test/integration/testdata/custom,k8s.io/kube-openapi/test/integration/testdata/listtype,k8s.io/kube-openapi/test/integration/testdata/maptype,k8s.io/kube-openapi/test/integration/testdata/structtype,k8s.io/kube-openapi/test/integration/testdata/dummytype,k8s.io/kube-openapi/test/integration/testdata/uniontype,k8s.io/kube-openapi/test/integration/testdata/defaults" \
-i "k8s.io/kube-openapi/test/integration/testdata/custom,k8s.io/kube-openapi/test/integration/testdata/enumtype,k8s.io/kube-openapi/test/integration/testdata/listtype,k8s.io/kube-openapi/test/integration/testdata/maptype,k8s.io/kube-openapi/test/integration/testdata/structtype,k8s.io/kube-openapi/test/integration/testdata/dummytype,k8s.io/kube-openapi/test/integration/testdata/uniontype,k8s.io/kube-openapi/test/integration/testdata/defaults" \
-o pkg \
-p generated \
-O openapi_generated \
Expand All @@ -42,7 +42,7 @@ If you've created a new type, make sure you add it in `createWebServices()` in
---
**NOTE:**

If you've created a new package, make sure you also add it to to the
If you've created a new package, make sure you also add it to the
`inputDir` in `integration_suite_test.go`.
---

Expand Down
11 changes: 7 additions & 4 deletions test/integration/integration_suite_test.go
Expand Up @@ -29,6 +29,7 @@ import (
)

const (
headerFilePath = "../../boilerplate/boilerplate.go.txt"
testdataDir = "./testdata"
testPkgDir = "k8s.io/kube-openapi/test/integration/testdata"
inputDir = testPkgDir + "/listtype" +
Expand Down Expand Up @@ -78,9 +79,9 @@ var _ = Describe("Open API Definitions Generation", func() {

// Build the OpenAPI code generator.
By("building openapi-gen")
binary_path, berr := gexec.Build("../../cmd/openapi-gen/openapi-gen.go")
binaryPath, berr := gexec.Build("../../cmd/openapi-gen/openapi-gen.go")
Expect(berr).ShouldNot(HaveOccurred())
openAPIGenPath = binary_path
openAPIGenPath = binaryPath

// Run the OpenAPI code generator, creating OpenAPIDefinition code
// to be compiled into builder.
Expand All @@ -92,6 +93,7 @@ var _ = Describe("Open API Definitions Generation", func() {
"-p", outputPackage,
"-O", outputBaseFileName,
"-r", gr,
"-h", headerFilePath,
)
command.Dir = workingDirectory
session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
Expand All @@ -100,13 +102,13 @@ var _ = Describe("Open API Definitions Generation", func() {

By("writing swagger")
// Create the OpenAPI swagger builder.
binary_path, berr = gexec.Build("./builder/main.go")
binaryPath, berr = gexec.Build("./builder/main.go")
Expect(berr).ShouldNot(HaveOccurred())

// Execute the builder, generating an OpenAPI swagger file with definitions.
gs := generatedFile(generatedSwaggerFileName)
By("writing swagger to " + gs)
command = exec.Command(binary_path, gs)
command = exec.Command(binaryPath, gs)
command.Dir = workingDirectory
session, err = gexec.Start(command, GinkgoWriter, GinkgoWriter)
Expect(err).ShouldNot(HaveOccurred())
Expand All @@ -126,6 +128,7 @@ var _ = Describe("Open API Definitions Generation", func() {
"-p", outputPackage,
"-O", outputBaseFileName,
"-r", testdataFile(goldenReportFileName),
"-h", headerFilePath,
"--verify-only",
)
command.Dir = workingDirectory
Expand Down
3 changes: 2 additions & 1 deletion test/integration/pkg/generated/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 00f4ec9

Please sign in to comment.