Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flesh out client tests #252

Merged
merged 13 commits into from
Oct 23, 2024
Merged

Flesh out client tests #252

merged 13 commits into from
Oct 23, 2024

Conversation

tstirrat15
Copy link
Contributor

Description

We had a user asking in Discord about how to consume a server stream, and I was going to point them at the tests when I realized that we don't actually have those tests in this repo. This is more about having a mechanism for documentation than about any concern about correctness.

Changes

  • Add uuid as an explicit dep for generating test tokens
  • Add the Conn as a member of the client struct so that callers can do things like teardown logic
  • Make tests match what's in authzed-dotnet

Testing

Review, see that things are green

@tstirrat15 tstirrat15 requested a review from a team as a code owner October 22, 2024 19:00
v1/client_test.go Outdated Show resolved Hide resolved
v1/client_test.go Outdated Show resolved Hide resolved
v1/client_test.go Outdated Show resolved Hide resolved
v1/client_test.go Show resolved Hide resolved
require.NoError(err)
}

func TestCheck(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if these should be Examples and not Tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're tests in the other repositories, and I want them to be exercised by the test harness to demonstrate that they currently work with the library.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Examples get run with go test they just also show up in the docs as examples

@tstirrat15
Copy link
Contributor Author

@ecordell i'm also a little worried that I have a flake in the BulkImportExportTest. is there anything obviously borked with it?

v1/client_test.go Show resolved Hide resolved
v1/client_test.go Show resolved Hide resolved
v1/client_test.go Outdated Show resolved Hide resolved
require.NoError(err)

// Validate export
exportResponse, err := client.PermissionsServiceClient.ExportBulkRelationships(context.Background(), &v1.ExportBulkRelationshipsRequest{})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since these are meant as examples, maybe it would be good to make a context with cancellation and pass it in?

ctx, cancel := context.WithCancel(context.Background())
t.Cleanup(cancel)

ctx = context.WithTimeout(ctx, 5*time.Second)

etc

v1/client_test.go Show resolved Hide resolved
v1/client.go Outdated
@@ -11,6 +11,9 @@ import (
//
// Clients are backed by a gRPC client and as such are thread-safe.
type Client struct {
// Provide a handle on the underlying connection to enable cleanup
// behaviors (among others)
Conn *grpc.ClientConn
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's make this conn (private) and then add a top level func (Client) Close() error method?

Copy link
Contributor

@ecordell ecordell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tstirrat15 tstirrat15 added this pull request to the merge queue Oct 23, 2024
@tstirrat15 tstirrat15 removed this pull request from the merge queue due to a manual request Oct 23, 2024
@tstirrat15 tstirrat15 added this pull request to the merge queue Oct 23, 2024
Merged via the queue into main with commit d740bc0 Oct 23, 2024
10 checks passed
@tstirrat15 tstirrat15 deleted the flesh-out-tests branch October 23, 2024 16:59
@github-actions github-actions bot locked and limited conversation to collaborators Oct 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants