mirror of
https://github.com/rustfs/console.git
synced 2026-08-30 17:14:47 +08:00
25 lines
1.1 KiB
JavaScript
25 lines
1.1 KiB
JavaScript
import test from "node:test"
|
|
import assert from "node:assert/strict"
|
|
import { readFile } from "node:fs/promises"
|
|
import {
|
|
resolveBucketVersioningState,
|
|
shouldForceDeleteObjects,
|
|
shouldShowDeleteAllVersions,
|
|
} from "../../lib/object-delete.ts"
|
|
|
|
const objectListSource = await readFile(new URL("../../components/object/list.tsx", import.meta.url), "utf8")
|
|
|
|
test("unknown bucket versioning state never enables force delete", () => {
|
|
assert.equal(resolveBucketVersioningState("Enabled"), "enabled")
|
|
assert.equal(shouldShowDeleteAllVersions("unknown"), false)
|
|
assert.equal(shouldForceDeleteObjects("unknown", false), false)
|
|
assert.equal(shouldForceDeleteObjects("disabled", false), true)
|
|
})
|
|
|
|
test("object deletion stays blocked until versioning state is known", () => {
|
|
assert.match(objectListSource, /setBucketVersioningState\("unknown"\)/)
|
|
assert.match(objectListSource, /bucketVersioningState === "unknown"/)
|
|
assert.doesNotMatch(objectListSource, /object-versioning-status/)
|
|
assert.doesNotMatch(objectListSource, /catch\s*\{[\s\S]{0,120}setBucketVersioningState\("disabled"\)/)
|
|
})
|