package com.yimeng.okr.config;

import org.junit.jupiter.api.Test;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.Statement;

import static org.mockito.Mockito.*;

class DatabaseInitializerTest {

    @Test
    void runBackfillsLegacyFinalScoreStatus() throws Exception {
        DataSource dataSource = mock(DataSource.class);
        Connection connection = mock(Connection.class);
        Statement statement = mock(Statement.class);
        when(dataSource.getConnection()).thenReturn(connection);
        when(connection.createStatement()).thenReturn(statement);

        new DatabaseInitializer(dataSource).run();

        verify(statement).execute("PRAGMA journal_mode=WAL");
        verify(statement).execute("PRAGMA foreign_keys=ON");
    }
}
