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

Refactor server test setup code #363

Open
yuryu opened this issue Jul 23, 2022 · 0 comments
Open

Refactor server test setup code #363

yuryu opened this issue Jul 23, 2022 · 0 comments

Comments

@yuryu
Copy link
Member

yuryu commented Jul 23, 2022

Many tests in open_savess_test.go has seven lines for setup if they need a store and a record to work with.

	ctx := context.Background()
	_, listener := getOpenSavesServer(ctx, t, "gcp")
	_, client := getTestClient(ctx, t, listener)
	store := &pb.Store{Key: uuid.NewString()}
	setupTestStore(ctx, t, client, store)
	record := &pb.Record{Key: uuid.NewString()}
	record = setupTestRecord(ctx, t, client, store.Key, record)

This can and should be shorter, for example,

  1. create context
  2. create client
  3. create a default store and record

Also, tests use uuid as store and record keys to avoid conflicts, but something more predictable would be better for debugging. For example, "test name YYYY-MM-DD HH:mm:ss UUID" would let you know which entity corresponds to which test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant