Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
waciumawanjohi committed Aug 3, 2023
1 parent 1e5d7f8 commit 40919c0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 28 deletions.
14 changes: 7 additions & 7 deletions content/docs/v0.7.0/cartotest-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
38 changes: 17 additions & 21 deletions content/docs/v0.7.0/cartotest-go.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,27 +79,24 @@ 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
- WorkloadObject, which provides a go cartographer workload object. Example: # TODO: point to example

#### 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)
Expand Down Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions content/docs/v0.7.0/testing-templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 40919c0

Please sign in to comment.