Delimiter //
/**
 * test of LOADER_MATCHINGCODE_NORMALIZE_MAP_DATE_NOT_PROVIDED()
 * @test
 */
Drop Procedure If Exists TEST_LOADER_MATCHINGCODE_MAP_DATE_NOT_PROVIDED//

Create Procedure TEST_LOADER_MATCHINGCODE_MAP_DATE_NOT_PROVIDED()
Begin

    Set @batchnum = 1;
    Set @id_loader_status = 1;

    Call LOADER_TEST_MOCK_MATCHINGCODES_CLEAN();
    Call LOADER_TEST_MOCK_MATCHINGCODES_PUSH(1,'MATCHINGCODES_DATE = Null', @id_loader_status , Null); 
    Call LOADER_TEST_MOCK_MATCHINGCODES_PUSH(2,'MATCHINGCODES_DATE = ''2012-05-25''', @id_loader_status , Null); 
    
    -- Tested procedure
    Call LOADER_MATCHINGCODE_NORMALIZE_MAP_DATE_NOT_PROVIDED(@batchnum);
    
    Call utAssert_eq('When no date is provided for an entry, row receives the current date'
        , Date(Now())
        , (SELECT MATCHINGCODES_DATE FROM LOADER_MATCHINGCODES WHERE ID_LOADER_MATCHINGCODES = 1)
    );
    Call utAssert_eq('When date is provided for an entry, this date is preserved'
        , '2012-05-25'
        , (SELECT MATCHINGCODES_DATE FROM LOADER_MATCHINGCODES WHERE ID_LOADER_MATCHINGCODES = 2)
    );
    Call LOADER_TEST_MOCK_MATCHINGCODES_CLEAN();

End//
Delimiter ;