Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a52e0bd6 authored by cketti's avatar cketti
Browse files

Avoid exception in MigrationTo43 during database tests

parent c3b4e0cf
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -258,6 +258,10 @@ public class LocalStore extends Store implements Serializable {
        database.switchProvider(newStorageProviderId);
    }

    Context getContext() {
        return context;
    }

    protected Account getAccount() {
        return mAccount;
    }
+1 −1
Original line number Diff line number Diff line
@@ -238,7 +238,7 @@ class StoreSchemaDefinition implements LockableDatabase.SchemaDefinition {

        @Override
        public Context getContext() {
            return localStore.context;
            return localStore.getContext();
        }

        @Override
+10 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ import java.util.List;

import android.app.Application;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

@@ -14,6 +15,7 @@ import com.fsck.k9.Account;
import com.fsck.k9.BuildConfig;
import com.fsck.k9.GlobalsHelper;
import com.fsck.k9.K9;
import com.fsck.k9.R;
import com.fsck.k9.mail.MessagingException;
import org.junit.Before;
import org.junit.Test;
@@ -316,16 +318,24 @@ public class StoreSchemaDefinitionTest {
    }

    private StoreSchemaDefinition createStoreSchemaDefinition() throws MessagingException {
        Context context = createContext();
        Account account = createAccount();
        LockableDatabase lockableDatabase = createLockableDatabase();

        LocalStore localStore = mock(LocalStore.class);
        localStore.database = lockableDatabase;
        when(localStore.getContext()).thenReturn(context);
        when(localStore.getAccount()).thenReturn(account);

        return new StoreSchemaDefinition(localStore);
    }

    private Context createContext() {
        Context context = mock(Context.class);
        when(context.getString(R.string.special_mailbox_name_outbox)).thenReturn("Outbox");
        return context;
    }

    private LockableDatabase createLockableDatabase() throws MessagingException {
        LockableDatabase lockableDatabase = mock(LockableDatabase.class);
        when(lockableDatabase.execute(anyBoolean(), any(LockableDatabase.DbCallback.class))).thenReturn(false);