Debian Codegraph @

test/integration/README.md

raw
1 # Kube OpenAPI Integration Tests
2
3 ## Running the integration tests
4
5 Within the current directory:
6
7 ```bash
8 $ go test -v .
9 ```
10
11 ## Generating the golden Swagger definition file and API rule violation report
12
13 First, run the generator to create `openapi_generated.go` file which specifies
14 the `OpenAPIDefinition` for each type, and generate the golden API rule
15 violation report file. Note that if you do not pass a report
16 filename (`./testdata/golden.v2.report` in the command below) to let the generator
17 to print API rule violations to the file, the generator will return error to stderr
18 on API rule violations.
19
20 ```bash
21 $ go run ../../cmd/openapi-gen/openapi-gen.go \
22 --output-dir pkg/generated \
23 --output-pkg generated \
24 --output-file openapi_generated.go \
25 --go-header-file ../../boilerplate/boilerplate.go.txt \
26 --report-filename ./testdata/golden.v2.report \
27 ./testdata/custom ./testdata/enumtype ./testdata/listtype ./testdata/maptype ./testdata/structtype ./testdata/dummytype ./testdata/uniontype ./testdata/defaults ./testdata/valuevalidation
28
29 $ go run ../../cmd/openapi-gen/openapi-gen.go \
30 --output-dir pkg/generated/namedmodels \
31 --output-pkg generated/namedmodels \
32 --output-file openapi_generated.go \
33 --output-model-name-file zz_generated_model_name.go \
34 --go-header-file ../../boilerplate/boilerplate.go.txt \
35 --report-filename ./testdata/namedmodels/golden.v3.report \
36 ./testdata/namedmodels
37 ```
38 The generated file `pkg/generated/openapi_generated.go` should have been created.
39
40 Next, run the OpenAPI builder to create the Swagger file which includes
41 the definitions. The output file named `golden.v2.json` (or v3) will be output in
42 the current directory.
43
44 ```bash
45 $ go run builder/main.go testdata/golden.v2.json
46 $ go run builder3/main.go testdata/golden.v3.json
47 ```
48
49 ❗NOTE❗: If you've created a new type, make sure you add it in `createWebServices()` in
50 `./builder/main.go`, or the definitions won't be generated.
51
52 ❗NOTE❗: If you've created a new package, make sure you also add it to the
53 `inputDir` in `integration_suite_test.go`.