Search in sources :

Example 6 with Target

use of com.google.firebase.firestore.proto.Target in project firebase-android-sdk by firebase.

the class SQLiteSchemaTest method keepsLastLimboFreeSnapshotIfNotDowngraded.

@Test
public void keepsLastLimboFreeSnapshotIfNotDowngraded() {
    schema.runSchemaUpgrades(0, 9);
    db.execSQL("INSERT INTO targets (target_id, canonical_id, target_proto) VALUES (?,?, ?)", new Object[] { 1, "foo", createDummyQueryTargetWithLimboFreeVersion(1).toByteArray() });
    // Make sure that we don't drop the lastLimboFreeSnapshotVersion if we are already on schema
    // version 9.
    schema.runSchemaUpgrades(9, 9);
    new SQLitePersistence.Query(db, "SELECT target_proto FROM targets").forEach(cursor -> {
        byte[] targetProtoBytes = cursor.getBlob(0);
        try {
            Target targetProto = Target.parseFrom(targetProtoBytes);
            assertTrue(targetProto.hasLastLimboFreeSnapshotVersion());
        } catch (InvalidProtocolBufferException e) {
            fail("Failed to decode Target data");
        }
    });
}
Also used : Target(com.google.firebase.firestore.proto.Target) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) Test(org.junit.Test)

Aggregations

Target (com.google.firebase.firestore.proto.Target)6 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)6 Test (org.junit.Test)4 Query (com.google.firebase.firestore.core.Query)1