Delimiter //
/**
 * test of LOADER_ENTRIES_NORMALIZE_MAP_DATE_NOTPROVIDED()
 * @test
 */
Drop Procedure If Exists TEST_LOADER_ENTRIES_MAP_DATE_NOTPROVIDED//

Create Procedure TEST_LOADER_ENTRIES_MAP_DATE_NOTPROVIDED()
Begin

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

    Call LOADER_TEST_MOCK_ENTRIES_CLEAN();
    call LOADER_TEST_MOCK_ENTRIES_PUSH(1,'ID_ENTRIES_NEW = 1, ENTRIES_DATE = Null', @id_loader_status , Null); 
    call LOADER_TEST_MOCK_ENTRIES_PUSH(2,'ID_ENTRIES_NEW = 2, ENTRIES_DATE = ''2012-05-25''', @id_loader_status , Null); 
    
    -- Tested procedure
    call LOADER_ENTRIES_NORMALIZE_MAP_DATE_NOTPROVIDED(@batchnum);
    
    CALL utAssert_eq('When no date is provided for an entry, row receives the current date'
        , Date(Now())
        , (SELECT ENTRIES_DATE FROM LOADER_ENTRIES WHERE ID_LOADER_ENTRIES = 1)
    );
    CALL utAssert_eq('When date is provided for an entry, this date is preserved'
        , '2012-05-25'
        , (SELECT ENTRIES_DATE FROM LOADER_ENTRIES WHERE ID_LOADER_ENTRIES = 2)
    );
    Call LOADER_TEST_MOCK_ENTRIES_CLEAN();

End//
Delimiter ;