-
Notifications
You must be signed in to change notification settings - Fork 821
Expand file tree
/
Copy pathconfiguration-loader.test.ts
More file actions
83 lines (74 loc) · 2.39 KB
/
configuration-loader.test.ts
File metadata and controls
83 lines (74 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/**
* Tests for ConfigurationLoader
* **Feature: amplify-gen1-to-gen2-migration-script, Property 1: Configuration validation consistency**
*/
import { ConfigurationLoader } from '../core/configuration-loader';
import { Logger } from '../utils/logger';
import { FileManager } from '../utils/file-manager';
import { LogLevel, AppConfiguration } from '../types';
describe('ConfigurationLoader', () => {
let logger: Logger;
let fileManager: FileManager;
let configLoader: ConfigurationLoader;
beforeEach(() => {
logger = new Logger(LogLevel.ERROR); // Suppress logs during tests
fileManager = new FileManager(logger);
configLoader = new ConfigurationLoader(logger, fileManager, './test-apps');
});
describe('validateConfiguration', () => {
it('should validate a complete valid configuration', () => {
const validConfig: AppConfiguration = {
app: {
name: 'testapp',
description: 'Test application',
framework: 'react',
},
categories: {
api: {
type: 'GraphQL',
authModes: ['API_KEY', 'COGNITO_USER_POOLS'],
},
auth: {
signInMethods: ['email'],
socialProviders: [],
},
storage: {
buckets: [
{
name: 'test-bucket',
access: ['auth', 'guest'],
},
],
},
function: {
functions: [
{
name: 'test-function',
runtime: 'nodejs',
},
],
},
},
};
const result = configLoader.validateConfiguration(validConfig);
expect(result.errors).toHaveLength(0);
});
it('should reject configuration without app metadata', () => {
const invalidConfig = {
categories: {},
} as AppConfiguration;
const result = configLoader.validateConfiguration(invalidConfig);
expect(result.errors).toContain('App metadata is required');
});
it('should reject configuration without categories', () => {
const invalidConfig = {
app: {
name: 'testapp',
description: 'Test application',
},
} as AppConfiguration;
const result = configLoader.validateConfiguration(invalidConfig);
expect(result.errors).toContain('Categories configuration is required');
});
});
});