I have an SQL macro which in turn creates a SQL procedure in pre-hook.
I also have some macros with some simple logic.
I tried many things but none of them actually worked for testing my macro code as standalone unit test.
Sample macro I am adding below:
{% macro map_gender() %}
CREATE OR REPLACE FUNCTION map_gender(gender_code text)
RETURNS text
AS $$
BEGIN
CASE gender_code
WHEN '1' THEN RETURN 'MALE';
WHEN '2' THEN RETURN 'FEMALE';
WHEN 'M' THEN RETURN 'MALE';
WHEN 'F' THEN RETURN 'FEMALE';
WHEN '0' THEN RETURN 'OTHERS';
WHEN 'U' THEN RETURN 'OTHERS';
WHEN null THEN RETURN '';
ELSE RETURN gender_code;
END CASE;
END;
$$ LANGUAGE plpgsql;
{% endmacro %}
How, can I write unit test case with some assertions. Given the input and expected output test case should pass or fail.