From 40919c07ec869ec444271c558ace2c8de9b237cc Mon Sep 17 00:00:00 2001 From: Waciuma Wanjohi Date: Tue, 20 Jun 2023 17:31:12 -0400 Subject: [PATCH] Lint --- content/docs/v0.7.0/cartotest-cli.md | 14 ++++----- content/docs/v0.7.0/cartotest-go.md | 38 +++++++++++------------- content/docs/v0.7.0/testing-templates.md | 1 + 3 files changed, 25 insertions(+), 28 deletions(-) diff --git a/content/docs/v0.7.0/cartotest-cli.md b/content/docs/v0.7.0/cartotest-cli.md index ad32f9a2..e651c913 100644 --- a/content/docs/v0.7.0/cartotest-cli.md +++ b/content/docs/v0.7.0/cartotest-cli.md @@ -206,8 +206,8 @@ One or more supply chains may be specified. The supply chains may be specified i These methods are exclusive, not cumulative (i.e. if supply chains are found from method 1, method 2 will not contribute to the supply chain). -1. Files named in the `.given.supplyChain.paths` list of `info.yaml`. Paths may be to directories of files that are - all supply chains. +1. Files named in the `.given.supplyChain.paths` list of `info.yaml`. Paths may be to directories of files that are all + supply chains. 2. Files with the prefix `supply-chain` and the extension `.yaml` 3. The supply chain files inherited from parent directory @@ -245,17 +245,17 @@ There are several ways to exclude metadata fields from the comparison of stamped - To ignore the metadata.ignoreLabels field, in `info.yaml` specify `compareOptions.ignoreLabels: true` - To ignore other metadata fields, in `info.yaml` add the field name to the list `compareOptions.ignoreMetadataFields` -Comparison of objects can fail on type assertion (i.e. an expected field interpreted as the int 3 and the stamped -object with the same field as the float 3). There is a named function to coerce all numbers to the type float64. To -apply this function, in `info.yaml` add the name `ConvertNumbersToFloatsDuringComparison` to the list +Comparison of objects can fail on type assertion (i.e. an expected field interpreted as the int 3 and the stamped object +with the same field as the float 3). There is a named function to coerce all numbers to the type float64. To apply this +function, in `info.yaml` add the name `ConvertNumbersToFloatsDuringComparison` to the list `compareOptions.namedCMPOptionFuncs`. ## How-Tos ### Interpreting Failing Tests -Let's make a test fail. Alter the workload so that what is stamped out by Cartographer will be different -from `expected.yaml`: +Let's make a test fail. Alter the workload so that what is stamped out by Cartographer will be different from +`expected.yaml`: _The example edit uses mikefarah/yq for which you can find installation instructions [here](https://github.com/mikefarah/yq#install). Alternatively you can manually change the `metadata.name` field of diff --git a/content/docs/v0.7.0/cartotest-go.md b/content/docs/v0.7.0/cartotest-go.md index 703b0d34..bb4a2159 100644 --- a/content/docs/v0.7.0/cartotest-go.md +++ b/content/docs/v0.7.0/cartotest-go.md @@ -79,18 +79,16 @@ provision as a go object or as a yaml file. #### Template Interface -Template is one of the fields in [Given](#given). -There are two implementations of the template interface: +Template is one of the fields in [Given](#given). There are two implementations of the template interface: -- TemplateFile, which specifies the filepath of a yaml file of a Cartographer Template. It may also specify - the [YttFiles and YttValues fields](#ytt-templating). Example: # TODO: point to example +- TemplateFile, which specifies the filepath of a yaml file of a Cartographer Template. It may also specify the + [YttFiles and YttValues fields](#ytt-templating). Example: # TODO: point to example - TemplateObject, which provides a go instance of one of the cartographer template classes. Example: # TODO: point to example #### Workload Interface -Workload is one of the fields in [Given](#given). -There are two implementations of the workload interface: +Workload is one of the fields in [Given](#given). There are two implementations of the workload interface: - WorkloadFile, which specifies the filepath of a yaml file of a Cartographer Workload. Example: # TODO: point to example @@ -98,8 +96,7 @@ There are two implementations of the workload interface: #### SupplyChain Interface -SupplyChain is one of the fields in [Given](#given). -There are two implementations of the supply-chain interface: +SupplyChain is one of the fields in [Given](#given). There are two implementations of the supply-chain interface: - [SupplyChainFileSet](#supplychainfileset) - [MockSupplyChain](#mocksupplychain) @@ -134,27 +131,26 @@ MockSupplyChains allow mocking out the two types of values that a supply chain s of previous resources/stages. Each of these can be specified by pointing to a yaml file, or by creating a go object. - Inputs - - SupplyChainInputsObject: Define an inputs object. See example #TODO - - SupplyChainInputsFile: Provide the path of a yaml file defining - inputs. [See example](https://github.com/vmware-tanzu/cartographer/blob/d5a9e41294a6a04b8a03298a2d96610b6d2f0343/tests/templates/kpack/inputs-file-not-used-by-cli-tests.yaml) + - SupplyChainInputsObject: Define an inputs object. See example #TODO + - SupplyChainInputsFile: Provide the path of a yaml file defining inputs. + [See example](https://github.com/vmware-tanzu/cartographer/blob/d5a9e41294a6a04b8a03298a2d96610b6d2f0343/tests/templates/kpack/inputs-file-not-used-by-cli-tests.yaml) - Params - - SupplyChainParamsFile: Provide the path of a yaml file defining - params. [See example](https://github.com/vmware-tanzu/cartographer/blob/d5a9e41294a6a04b8a03298a2d96610b6d2f0343/tests/templates/deliverable/regular-template/params-file-not-used-by-cli-tests.yaml) - - SupplyChainParamsObject: Provide a params object. To simplify this process, Cartotest provides the - [BuildSupplyChainStringParams](# TODO) function. [Example usage](https://github.com/vmware-tanzu/cartographer/blob/d5a9e41294a6a04b8a03298a2d96610b6d2f0343/tests/templates/template_test.go#L34-L43) + - SupplyChainParamsFile: Provide the path of a yaml file defining params. + [See example](https://github.com/vmware-tanzu/cartographer/blob/d5a9e41294a6a04b8a03298a2d96610b6d2f0343/tests/templates/deliverable/regular-template/params-file-not-used-by-cli-tests.yaml) + - SupplyChainParamsObject: Provide a params object. To simplify this process, Cartotest provides the + [BuildSupplyChainStringParams](# TODO) function. + [Example usage](https://github.com/vmware-tanzu/cartographer/blob/d5a9e41294a6a04b8a03298a2d96610b6d2f0343/tests/templates/template_test.go#L34-L43) ##### Inputs vs Outputs It is important to note that inputs and outputs are slightly different: - [SupplyChainFileSet](#supplychainfileset) PreviousOutputs: provide the name of the previous resource that created the - output. The supply - chain spec will rename this input. Read more about that in - the [tutorials](tutorials/extending-a-supply-chain.md#supply-chain). + output. The supply chain spec will rename this input. Read more about that in the + [tutorials](tutorials/extending-a-supply-chain.md#supply-chain). - [MockSupplyChain](#mocksupplychain) Inputs: As we are mocking out the supply chain, we need not specify the previous - resource's name. - Instead we specify the name of the input as it is referred to in the template. Read more in - the [templating documentation](templating.md#inputs) + resource's name. Instead we specify the name of the input as it is referred to in the template. Read more in the + [templating documentation](templating.md#inputs) ### Expect diff --git a/content/docs/v0.7.0/testing-templates.md b/content/docs/v0.7.0/testing-templates.md index 02675718..86480e13 100644 --- a/content/docs/v0.7.0/testing-templates.md +++ b/content/docs/v0.7.0/testing-templates.md @@ -10,5 +10,6 @@ outputs from earlier steps in the supply chain may also be mocked. The object st object). Read more: + - [Cartotest as a go testing framework](cartotest-go.md) - [Cartotest as a CLI](cartotest-cli.md)