Skip to content

Commit

Permalink
Make Client E2E tests more flexible (#150)
Browse files Browse the repository at this point in the history
* Rename e2e_tests to e2e_tests

Signed-off-by: Will Beason <willbeason@google.com>

* Make tests more flexible

Refactor tests so that:

- it is possible to specify rego and libraries per-test
- all tests use their own Client
- the Probe type is no longer necessary

Signed-off-by: Will Beason <willbeason@google.com>

* Use cmp.Diff to check for response differences

This makes test output on failure more consistent and clearer.

Use per-test Context instead of one shared between all tests. This
removes another avenue of test crosstalk and allows us to test things
like behavior with cancellable contexts.

Make response order more, but not completely, deterministic. We don't
need response order to be more deterministic for tests than what I've
put here, and as-is will make the output of reviewing objects more
consistent. There are common edge cases where ordering is randomized,
but this can be fully fixed later.

Comment out the contents of TestRemoteClientE2E. This test is currently
skipped until we have a working remote to connect the remote Driver to.
I've added clarifying comments to explain what we'll want once this
exists.

Signed-off-by: Will Beason <willbeason@google.com>

* Make reviewer-suggested changes

Signed-off-by: Will Beason <willbeason@google.com>
  • Loading branch information
Will Beason committed Nov 30, 2021
1 parent 217139c commit 0087992
Show file tree
Hide file tree
Showing 6 changed files with 743 additions and 730 deletions.
15 changes: 0 additions & 15 deletions constraint/pkg/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,6 @@ import (

const badRego = `asd{`

func TestClientE2E(t *testing.T) {
d := local.New()
p, err := NewProbe(d)
if err != nil {
t.Fatal(err)
}
for name, f := range p.TestFuncs() {
t.Run(name, func(t *testing.T) {
if err := f(); err != nil {
t.Fatal(err)
}
})
}
}

var _ TargetHandler = &badHandler{}

type badHandler struct {
Expand Down
Loading

0 comments on commit 0087992

Please sign in to comment.