Skip to content

Refactor server test setup code #363

@yuryu

Description

@yuryu

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions