github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/ui/src/util/events.spec.ts (about) 1 // Copyright 2018 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 import { assert } from "chai"; 12 import { EventInfo, getDroppedObjectsText } from "src/util/events"; 13 14 describe("getDroppedObjectsText", function() { 15 16 // The key indicating which objects were dropped in a DROP_DATABASE event has been 17 // renamed multiple times, creating bugs (e.g. #18523). This test won't fail if the 18 // key is renamed again on the Go side, but it at least tests that we can handle all 19 // existing versions. 20 it("returns a sentence for all versions of the dropped objects key", function() { 21 const commonProperties: EventInfo = { 22 User: "root", 23 DatabaseName: "foo", 24 }; 25 const versions: EventInfo[] = [ 26 { 27 ...commonProperties, 28 DroppedTables: ["foo", "bar"], 29 }, 30 { 31 ...commonProperties, 32 DroppedTablesAndViews: ["foo", "bar"], 33 }, 34 { 35 ...commonProperties, 36 DroppedSchemaObjects: ["foo", "bar"], 37 }, 38 ]; 39 40 const expected = "2 schema objects were dropped: foo, bar"; 41 42 versions.forEach((eventInfoVersion) => { 43 assert.equal(expected, getDroppedObjectsText(eventInfoVersion)); 44 }); 45 }); 46 47 });