test(02-01): add failing test stubs for all four generators
- rclone-conf.test.ts: azureblob/s3/s3-compatible fixtures, error cases - intune-install.test.ts: configPath, includeInstall, UTF-8 write, credential safety - intune-detection.test.ts: configPath, exit codes, stdout only (no STDERR contamination) - rmm-script.test.ts: configPath, includeInstall, ErrorActionPreference=Stop
This commit is contained in:
@@ -0,0 +1,149 @@
|
||||
// src/generators/rclone-conf.test.ts
|
||||
// Tests for buildRcloneConf — rclone INI config generator.
|
||||
// RED: imports will fail until Plan 02-02 creates rclone-conf.ts.
|
||||
|
||||
import { buildRcloneConf } from './rclone-conf';
|
||||
import { INITIAL_STATE } from '../store/types';
|
||||
import type { WizardState } from '../store/types';
|
||||
|
||||
// --- Fixtures ---
|
||||
|
||||
const azureState: WizardState = {
|
||||
...INITIAL_STATE,
|
||||
remote: {
|
||||
name: 'my-azure',
|
||||
backendType: 'azureblob',
|
||||
params: { account: 'mystorageaccount', key: 'BASE64KEY', sas_url: '' },
|
||||
},
|
||||
};
|
||||
|
||||
const s3State: WizardState = {
|
||||
...INITIAL_STATE,
|
||||
remote: {
|
||||
name: 'my-s3',
|
||||
backendType: 's3',
|
||||
params: {
|
||||
provider: 'AWS',
|
||||
access_key_id: 'AKID',
|
||||
secret_access_key: 'SKEY',
|
||||
region: 'us-east-1',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const s3CompatibleState: WizardState = {
|
||||
...INITIAL_STATE,
|
||||
remote: {
|
||||
name: 'my-wasabi',
|
||||
backendType: 's3-compatible',
|
||||
params: {
|
||||
provider: 'Other',
|
||||
access_key_id: 'WCID',
|
||||
secret_access_key: 'WSKEY',
|
||||
endpoint: 'https://s3.wasabisys.com',
|
||||
region: '',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// --- Tests ---
|
||||
|
||||
describe('buildRcloneConf — azureblob', () => {
|
||||
it('contains the remote section header', () => {
|
||||
const output = buildRcloneConf(azureState);
|
||||
expect(output).toContain('[my-azure]');
|
||||
});
|
||||
|
||||
it('contains type = azureblob', () => {
|
||||
const output = buildRcloneConf(azureState);
|
||||
expect(output).toContain('type = azureblob');
|
||||
});
|
||||
|
||||
it('contains account value', () => {
|
||||
const output = buildRcloneConf(azureState);
|
||||
expect(output).toContain('account = mystorageaccount');
|
||||
});
|
||||
|
||||
it('contains key value', () => {
|
||||
const output = buildRcloneConf(azureState);
|
||||
expect(output).toContain('key = BASE64KEY');
|
||||
});
|
||||
|
||||
it('omits sas_url when empty', () => {
|
||||
const output = buildRcloneConf(azureState);
|
||||
expect(output).not.toContain('sas_url');
|
||||
});
|
||||
});
|
||||
|
||||
describe('buildRcloneConf — s3', () => {
|
||||
it('contains the remote section header', () => {
|
||||
const output = buildRcloneConf(s3State);
|
||||
expect(output).toContain('[my-s3]');
|
||||
});
|
||||
|
||||
it('contains type = s3', () => {
|
||||
const output = buildRcloneConf(s3State);
|
||||
expect(output).toContain('type = s3');
|
||||
});
|
||||
|
||||
it('contains provider = AWS', () => {
|
||||
const output = buildRcloneConf(s3State);
|
||||
expect(output).toContain('provider = AWS');
|
||||
});
|
||||
|
||||
it('contains access_key_id', () => {
|
||||
const output = buildRcloneConf(s3State);
|
||||
expect(output).toContain('access_key_id = AKID');
|
||||
});
|
||||
|
||||
it('contains secret_access_key', () => {
|
||||
const output = buildRcloneConf(s3State);
|
||||
expect(output).toContain('secret_access_key = SKEY');
|
||||
});
|
||||
|
||||
it('contains region', () => {
|
||||
const output = buildRcloneConf(s3State);
|
||||
expect(output).toContain('region = us-east-1');
|
||||
});
|
||||
});
|
||||
|
||||
describe('buildRcloneConf — s3-compatible', () => {
|
||||
it('uses type = s3 (not type = s3-compatible)', () => {
|
||||
const output = buildRcloneConf(s3CompatibleState);
|
||||
expect(output).toContain('type = s3');
|
||||
expect(output).not.toContain('type = s3-compatible');
|
||||
});
|
||||
|
||||
it('contains provider = Other', () => {
|
||||
const output = buildRcloneConf(s3CompatibleState);
|
||||
expect(output).toContain('provider = Other');
|
||||
});
|
||||
|
||||
it('contains endpoint', () => {
|
||||
const output = buildRcloneConf(s3CompatibleState);
|
||||
expect(output).toContain('endpoint = https://s3.wasabisys.com');
|
||||
});
|
||||
|
||||
it('omits region when empty', () => {
|
||||
const output = buildRcloneConf(s3CompatibleState);
|
||||
expect(output).not.toContain('region');
|
||||
});
|
||||
});
|
||||
|
||||
describe('buildRcloneConf — error cases', () => {
|
||||
it('throws when backendType is null', () => {
|
||||
const state: WizardState = {
|
||||
...INITIAL_STATE,
|
||||
remote: { name: 'test', backendType: null, params: {} },
|
||||
};
|
||||
expect(() => buildRcloneConf(state)).toThrow();
|
||||
});
|
||||
|
||||
it('throws when remote name is empty string', () => {
|
||||
const state: WizardState = {
|
||||
...INITIAL_STATE,
|
||||
remote: { name: '', backendType: 'azureblob', params: { account: 'acc', key: 'k', sas_url: '' } },
|
||||
};
|
||||
expect(() => buildRcloneConf(state)).toThrow();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user