Skip to content

Commit

Permalink
docs: note about integration test in readme, helpful error message
Browse files Browse the repository at this point in the history
  • Loading branch information
zjrgov committed Dec 19, 2024
1 parent 538057c commit edd8bb4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
11 changes: 11 additions & 0 deletions runner/cf-driver-go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,23 @@ go get github.com/google/some-mod/pkg

## Running tests

### Unit tests

The simplest way to run tests—or the one with the least typing, at least—is with `make`.

```sh
make test
```

### Integration tests

We only have one integration test right now, and to get it running you'll need to do a bit of local setup.

1. You will need to first get a username & password for some space on cloud.gov that has at least one app.
1. Then you can add those credentials to `./cg/testdata/.cg_creds` in the style of the `.cg_creds.sample` file there.
1. Run the test with `make integration`, which should give you an error and, in its output, show you what the resulting JSON looks like.
1. Copy that JSON result over to the last line of your `.cg_creds` file and run `make integration` again, this time it should succeed.

## Builds

You can also run a build with `make` (`make build`, or simply `make`), but it won't do you much good because we aren't set up to do anything with an executable yet.
9 changes: 7 additions & 2 deletions runner/cf-driver-go/cg/cg_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ func Test_CFAdapter_GetApps(t *testing.T) {
var u, p, want string
var l int

f, err := os.Open("./testdata/.cg_creds")
path := "./testdata/.cg_creds"
f, err := os.Open(path)
if err != nil {
t.Errorf("Error opening testdata file = %v", err)
t.Errorf(
"Error opening testdata file = %v\n\033[1;33mDid you forget to create `%v`?\033[0m",
err, path,
)
return
}
defer f.Close()

Expand Down

0 comments on commit edd8bb4

Please sign in to comment.