Skip to content

Commit

Permalink
bug: add test for else with records (#677)
Browse files Browse the repository at this point in the history
Debugging else with records does appear to work. Added a test for future
regression verification.
  • Loading branch information
kevinjnguyen authored Aug 18, 2023
1 parent c87108a commit b84cf12
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
27 changes: 27 additions & 0 deletions python/pytests/else_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,30 @@ def test_else_(source, golden) -> None:
}
)
)


@pytest.fixture(scope="module")
def record_source() -> kd.sources.JsonlString:
content = "\n".join(
[
"""{"time":"1996-12-19T16:39:57","key":"A","override": {"test":"override_val"}}""",
"""{"time":"1996-12-19T16:39:58","key":"A","default_record":{"test":"default"}}""",
]
)
return kd.sources.JsonlString(
content, time_column_name="time", key_column_name="key"
)


def test_else_debug(record_source, golden) -> None:
default_record = record_source.col("default_record")
override_column = record_source.col("override")
golden.jsonl(
kd.record(
{
"default_record": default_record,
"overide": override_column,
"override_else_default": override_column.else_(default_record),
}
)
)
2 changes: 2 additions & 0 deletions python/pytests/golden/else_test/test_else_debug.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{"_time":"1996-12-19T16:39:57.000000000","_subsort":0,"_key_hash":12960666915911099378,"_key":"A","default_record":null,"overide":{"test":"override_val"},"override_else_default":{"test":"override_val"}}
{"_time":"1996-12-19T16:39:58.000000000","_subsort":1,"_key_hash":12960666915911099378,"_key":"A","default_record":{"test":"default"},"overide":null,"override_else_default":{"test":"default"}}

0 comments on commit b84cf12

Please sign in to comment.