"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const tape_1 = tslib_1.__importDefault(require("tape"));
const sinon_1 = tslib_1.__importDefault(require("sinon"));
const restore_1 = require("../restore");
const utils = tslib_1.__importStar(require("../utils"));
tape_1.default('derive resource name', t => {
    const sandbox = sinon_1.default.createSandbox();
    const rand = 'abcd';
    sandbox.stub(utils, 'randomAlphaNumericString').returns(rand);
    const stackName = 'tdl-blah1-ltd-dev';
    t.equal(restore_1.deriveRestoredResourceName({
        stackName,
        type: 'bucket',
        name: 'objects',
        value: 'tdl-abracadabra-ltd-dev-buckets-1kkkta6xsthmf-objects-1hf8k2xvzdryw',
    }), `${stackName}-objects-${rand}-r1`, 'derive restored version name from original');
    t.equal(restore_1.deriveRestoredResourceName({
        stackName,
        type: 'bucket',
        name: 'objectsbucket',
        value: 'tdl-abracadabra-ltd-dev-buckets-1kkkta6xsthmf-objects-1hf8k2xvzdryw',
    }), `${stackName}-objects-${rand}-r1`, 'strip resource type from name');
    t.equal(restore_1.deriveRestoredResourceName({
        stackName,
        type: 'bucket',
        name: 'objectsbucket',
        value: 'tdl-abracadabra-ltd-dev-buckets-1kkkta6xsthmf-objects-1hf8k2xvzdryw-r1',
    }), `${stackName}-objects-${rand}-r2`, 'derive restored version name from previous restored version');
    t.equal(restore_1.deriveRestoredResourceName({
        stackName,
        type: 'table',
        name: 'eventstable',
        value: 'tdl-abracadabra-ltd-dev-table-1kkkta6xsthmf-events-1hf8k2xvzdryw-r1',
    }), `${stackName}-events-r2`, 'add random suffix only for buckets');
    sandbox.restore();
    t.end();
});
//# sourceMappingURL=index.js.map