GOOD SHELL MAS BOY
Server: Apache/2.4.52 (Ubuntu)
System: Linux vmi1836763.contaboserver.net 5.15.0-130-generic #140-Ubuntu SMP Wed Dec 18 17:59:53 UTC 2024 x86_64
User: www-data (33)
PHP: 8.4.10
Disabled: NONE
Upload Files
File: //usr/local/lib/node_modules/firebase-tools/lib/firestore/api-sort.test.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const chai_1 = require("chai");
const firestore_1 = require("../gcp/firestore");
const proto_1 = require("../gcp/proto");
const sort = require("./api-sort");
describe("compareApiBackup", () => {
    it("should compare backups by location", () => {
        const nam5Backup = {
            name: "projects/example/locations/nam5/backups/backupid",
        };
        const usWest1Backup = {
            name: "projects/example/locations/us-west1/backups/backupid",
        };
        (0, chai_1.expect)(sort.compareApiBackup(usWest1Backup, nam5Backup)).to.greaterThanOrEqual(1);
        (0, chai_1.expect)(sort.compareApiBackup(nam5Backup, usWest1Backup)).to.lessThanOrEqual(-1);
    });
    it("should compare backups by snapshotTime (descending) if location is the same", () => {
        const earlierBackup = {
            name: "projects/example/locations/nam5/backups/backupid",
            snapshotTime: "2024-01-01T00:00:00.000000Z",
        };
        const laterBackup = {
            name: "projects/example/locations/nam5/backups/backupid",
            snapshotTime: "2024-02-02T00:00:00.000000Z",
        };
        (0, chai_1.expect)(sort.compareApiBackup(earlierBackup, laterBackup)).to.greaterThanOrEqual(1);
        (0, chai_1.expect)(sort.compareApiBackup(laterBackup, earlierBackup)).to.lessThanOrEqual(-1);
    });
    it("should compare backups by full name if location and snapshotTime are the same", () => {
        const nam5Backup1 = {
            name: "projects/example/locations/nam5/backups/earlier-backupid",
            snapshotTime: "2024-01-01T00:00:00.000000Z",
        };
        const nam5Backup2 = {
            name: "projects/example/locations/nam5/backups/later-backupid",
            snapshotTime: "2024-01-01T00:00:00.000000Z",
        };
        (0, chai_1.expect)(sort.compareApiBackup(nam5Backup2, nam5Backup1)).to.greaterThanOrEqual(1);
        (0, chai_1.expect)(sort.compareApiBackup(nam5Backup1, nam5Backup2)).to.lessThanOrEqual(-1);
    });
});
describe("compareApiBackupSchedule", () => {
    it("daily schedules should precede weekly ones", () => {
        const dailySchedule = {
            name: "projects/example/databases/mydatabase/backupSchedules/schedule",
            dailyRecurrence: {},
            retention: (0, proto_1.durationFromSeconds)(60 * 60 * 24),
        };
        const weeklySchedule = {
            name: "projects/example/databases/mydatabase/backupSchedules/schedule",
            weeklyRecurrence: {
                day: firestore_1.DayOfWeek.FRIDAY,
            },
            retention: (0, proto_1.durationFromSeconds)(60 * 60 * 24 * 7),
        };
        (0, chai_1.expect)(sort.compareApiBackupSchedule(weeklySchedule, dailySchedule)).to.greaterThanOrEqual(1);
        (0, chai_1.expect)(sort.compareApiBackup(dailySchedule, weeklySchedule)).to.lessThanOrEqual(-1);
    });
    it("should compare schedules with the same recurrence by name", () => {
        const dailySchedule1 = {
            name: "projects/example/databases/mydatabase/backupSchedules/schedule1",
            dailyRecurrence: {},
            retention: (0, proto_1.durationFromSeconds)(60 * 60 * 24),
        };
        const dailySchedule2 = {
            name: "projects/example/databases/mydatabase/backupSchedules/schedule2",
            dailyRecurrence: {},
            retention: (0, proto_1.durationFromSeconds)(60 * 60 * 24),
        };
        (0, chai_1.expect)(sort.compareApiBackupSchedule(dailySchedule1, dailySchedule2)).to.lessThanOrEqual(-1);
        (0, chai_1.expect)(sort.compareApiBackup(dailySchedule2, dailySchedule1)).to.greaterThanOrEqual(1);
    });
});