Skip to content

Commit 9a2fbfe

Browse files
authored
docs: add documentation on how to run tests (#2288)
Fixes #300
1 parent 6cf22a4 commit 9a2fbfe

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,14 @@ there are no such images published at the moment.
3434
See https://pkg.go.dev/github.com/googleapis/librarian/cmd/librarian for
3535
additional documentation.
3636

37+
## Running Tests
38+
39+
See [testing.md] for more information.
40+
3741
## License
3842

3943
Apache 2.0 - See [LICENSE] for more information.
4044

4145
[contributing]: CONTRIBUTING.md
4246
[license]: LICENSE
47+
[testing.md]: doc/testing.md

doc/testing.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Testing
2+
3+
## Unit Tests
4+
5+
These tests are designed to test the internal librarian golang logic.
6+
7+
Usage:
8+
9+
```bash
10+
go test ./...
11+
```
12+
13+
## End-to-End (e2e) Tests
14+
15+
These tests are designed to test the CLI interface for each supported Librarian command
16+
on a local system. It tests the interface with docker using a fake repo and test docker
17+
image. These tests are run as presubmits and postsubmits via GitHub actions.
18+
19+
Setup:
20+
21+
```bash
22+
DOCKER_BUILDKIT=1 docker build \
23+
-f ./testdata/e2e-test.Dockerfile \
24+
-t test-image:latest \
25+
.
26+
```
27+
28+
Usage:
29+
30+
```bash
31+
go test -tags e2e
32+
```
33+
34+
## Integration Tests
35+
36+
These tests are designed to test interactions with remote systems (e.g. GitHub). These
37+
tests are **NOT** run automatically as they create pull requests and branches.
38+
39+
Usage:
40+
41+
```bash
42+
TEST_GITHUB_TOKEN=<a personal access token> \
43+
TEST_GITHUB_REPO=<URL of GitHub repo> \
44+
go test ./...
45+
```
46+
47+
Note: `TEST_GITHUB_TOKEN` must have write access to `TEST_GITHUB_REPO`.
48+
49+
Note: These tests are skipped unless these environment variables are set.

0 commit comments

Comments
 (0)