Skip to content

Commit

Permalink
Document Golang testing
Browse files Browse the repository at this point in the history
Signed-off-by: Marcela Melara <[email protected]>
  • Loading branch information
marcelamelara committed May 9, 2023
1 parent 4cda93e commit f986493
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ protos: go_setup
go_run:
go run examples/go/main.go

.PHONY: protos go_setup go_run
go_test: go_setup
go test ./...

.PHONY: protos go_setup go_run go_test
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ including, but not limited to, the following high-level examples:
- [validation model](validation.md)
- [ideas for future schemas](schema_ideas.md)
- [protobuf definitions](protos.md)
- [testing the implementations](testing.md)

[Binary Authorization]: https://cloud.google.com/binary-authorization
[SLSA Provenance]: https://slsa.dev/provenance
Expand Down
26 changes: 26 additions & 0 deletions docs/testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# in-toto attestation implementation tests

We provide a set of basic tests for the different language
bindings for the in-toto attestation layers.

## Testing the Go bindings

The go packages `go/v1` and `go/predicates` provide a number of tests
for the statement and predicate layers.

### Running the Go tests

To run all tests:

```shell
$ make go_test
```

### Writing new Go tests

Please use the standard [Golang testing package] to write tests
for new predicates. For example tests, take a look at the `*_test.go`
files in the `go/` directory tree.

At a minimum, we suggest testing JSON marshalling and unmarshalling
of the Go language bindings.
6 changes: 6 additions & 0 deletions go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ The Go bindings for the attestations layers and predicates are provided in
the `github.com/in-toto/attestation/go/v1` and
`github.com/in-toto/attestation/go/predicates` packages, respectively.

# Testing

See the [testing docs] for info and instructions for testing this implementation.

## Run the Go example

examples/go/main.go provides an example of how these protos can be used.
Expand All @@ -27,3 +31,5 @@ $ make go_run
Read statement with predicateType https://example.com/unknownPred2
Predicate fields:{key:"foo" value:{struct_value:{fields:{key:"bar" value:{string_value:"baz"}}}}}
```

[testing docs]: ../docs/testing.md#testing-the-go-bindings

0 comments on commit f986493

Please sign in to comment.