Skip to content

Debug method #23

Open
Open
@Sicria

Description

@Sicria

Is there a recommended way of debugging during tests?

I found myself needing to debug something and ended up using the following to achieve what I needed.

SELECT
  row_eq (
    $$
    SELECT json_agg(json_build_object(
          'user_id', user_id,
          'account_id', account_id,
          'account_role', account_role
    ))::text FROM basejump.account_user WHERE account_id = 'd126ecef-35f6-4b5d-9f28-d9f00a9fb46f';
    $$,
    ROW (json_build_object('user_id', 'log')::text),
    'LOG'
  );

This fails a test and logs the contents of the table.

# Failed test 1: "LOG"
#         have: ("[{""user_id"" : ""2ea7443e-a7b8-45e9-87c1-b40cb7f1f37d"", ""account_id"" : ""d126ecef-35f6-4b5d-9f28-d9f00a9fb46f"", ""account_role"" : ""owner""}]")
#         want: ("{""user_id"" : ""log""}")

Is there a better way to log data in tests?

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