PostgreSQL backup tool with Point-In-Time-Recovery and restore verification
TypeScript backupbackupsdatabasedatabase-backupdevopsdockergolangkubernetesmariadbmongodbmysqlpgpostgrespostgresqls3self-hostedsystem-administrationtoolsweb-ui
import { describe, expect, it } from 'vitest';
import { MattermostDeliveryMode } from './MattermostDeliveryMode';
import type { MattermostNotifier } from './MattermostNotifier';
import { validateMattermostNotifier } from './validateMattermostNotifier';
const emptyNotifier: MattermostNotifier = {
deliveryMode: MattermostDeliveryMode.WEBHOOK,
webhookUrl: '',
serverUrl: '',
botToken: '',
targetChannelName: '',
targetChannelId: '',
overrideUsername: '',
overrideIconUrl: '',
isInsecureSkipVerify: false,
};
const channelId = 'abcdefghijklmnopqrstuvwxyz';
describe('validateMattermostNotifier', () => {
it('requires a webhook URL on create in webhook mode', () => {
expect(validateMattermostNotifier(true, emptyNotifier)).toBe(false);
expect(
validateMattermostNotifier(true, {
...emptyNotifier,
webhookUrl: 'https://mattermost.example.com/hooks/key',
}),
).toBe(true);
});
it('allows a blank webhook URL on edit', () => {
expect(validateMattermostNotifier(false, emptyNotifier)).toBe(true);
});
it('requires server URL, token and channel ID on create in bot mode', () => {
const botNotifier: MattermostNotifier = {
...emptyNotifier,
deliveryMode: MattermostDeliveryMode.BOT,
serverUrl: 'https://mattermost.example.com',
botToken: 'token',
targetChannelId: channelId,
};
expect(validateMattermostNotifier(true, botNotifier)).toBe(true);
expect(validateMattermostNotifier(true, { ...botNotifier, serverUrl: '' })).toBe(false);
expect(validateMattermostNotifier(true, { ...botNotifier, botToken: '' })).toBe(false);
expect(validateMattermostNotifier(false, { ...botNotifier, botToken: '' })).toBe(true);
});
it('rejects a channel name pasted into the channel ID field', () => {
expect(
validateMattermostNotifier(true, {
...emptyNotifier,
deliveryMode: MattermostDeliveryMode.BOT,
serverUrl: 'https://mattermost.example.com',
botToken: 'token',
targetChannelId: 'town-square',
}),
).toBe(false);
});
});