platform icon indicating copy to clipboard operation
platform copied to clipboard

Policy: migrate integration test fixtures to sqlc models

Open jakedoublev opened this issue 1 year ago • 1 comments

Background

Policy db queries are being migrated from squirrel to sqlc (#864). We need to migrate the integration test fixture internal struct types into the sqlc models to avoid duplication and reduce dual maintenance burden.

https://github.com/opentdf/platform/blob/77f1e1140ffc134ce072ba2e79bd74426f8ee5f8/service/internal/fixtures/fixtures.go#L159

Acceptance Criteria

  1. internal fixtures types are removed in favor of generated models
  2. integration tests no longer use internal fixture types
  3. yaml fixtures in some form are preserved for ease of tests and local development provisioning

jakedoublev avatar Aug 21 '24 18:08 jakedoublev

Another reason to remove the fixtures is a disconnect between the fixture JSON struct tags snake_case and the generated proto struct tags which are snake_case in JSON but camelCase in the proto JSON. This means marshaling protos to the database JSONB columns results in camelCase, but our fixtures have historically stored the columns in snake_case. This difference is experienced when using json.Marshal instead of protojson.Marshal.

The fixture types could be read into protos as needed to resolve this, but it would be additional work to fix the fixtures we are intending to deprecate in this issue.

jakedoublev avatar Oct 29 '24 19:10 jakedoublev