Skip to content

Commit fc0dd15

Browse files
committed
Document Golang testing
Signed-off-by: Marcela Melara <[email protected]>
1 parent 4cda93e commit fc0dd15

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@ protos: go_setup
99
go_run:
1010
go run examples/go/main.go
1111

12-
.PHONY: protos go_setup go_run
12+
go_test: go_setup
13+
go test ./...
14+
15+
.PHONY: protos go_setup go_run go_test

docs/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ including, but not limited to, the following high-level examples:
5252
- [validation model](validation.md)
5353
- [ideas for future schemas](schema_ideas.md)
5454
- [protobuf definitions](protos.md)
55+
- [testing the implementations](testing.md)
5556

5657
[Binary Authorization]: https://cloud.google.com/binary-authorization
5758
[SLSA Provenance]: https://slsa.dev/provenance

docs/testing.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# in-toto attestation implementation tests
2+
3+
We provide a set of basic tests for the different language
4+
bindings for the in-toto attestation layers.
5+
6+
## Testing the Go bindings
7+
8+
The go packages `go/v1` and `go/predicates` provide a number of tests
9+
for the statement and predicate layers.
10+
11+
### Running the Go tests
12+
13+
To run all tests:
14+
15+
```shell
16+
make go_test
17+
```
18+
19+
### Writing new Go tests
20+
21+
Please use the standard [Golang testing package] to write tests
22+
for new predicates. For example tests, take a look at the `*_test.go`
23+
files in the `go/` directory tree.
24+
25+
At a minimum, we suggest testing JSON marshalling and unmarshalling
26+
of the Go language bindings.

go/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ The Go bindings for the attestations layers and predicates are provided in
1515
the `github.com/in-toto/attestation/go/v1` and
1616
`github.com/in-toto/attestation/go/predicates` packages, respectively.
1717

18+
# Testing
19+
20+
See the [testing docs] for info and instructions for testing this implementation.
21+
1822
## Run the Go example
1923

2024
examples/go/main.go provides an example of how these protos can be used.
@@ -27,3 +31,5 @@ $ make go_run
2731
Read statement with predicateType https://example.com/unknownPred2
2832
Predicate fields:{key:"foo" value:{struct_value:{fields:{key:"bar" value:{string_value:"baz"}}}}}
2933
```
34+
35+
[testing docs]: ../docs/testing.md#testing-the-go-bindings

0 commit comments

Comments
 (0)