Repository navigation
Expand file tree
/
Copy pathfeature-setup.test.ts
More file actions
74 lines (69 loc) · 2.23 KB
/
Copy pathfeature-setup.test.ts
File metadata and controls
74 lines (69 loc) · 2.23 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
import {
SANDBOX_CAPABILITY,
validateCapabilityFieldInput,
} from '@sim/deployment-config/env-capabilities'
import { describe, expect, it } from 'vitest'
import type { ConfigurationSource } from './configuration-sources'
import { resolveFeatureSetupDestination } from './feature-setup'
const E2B_FUNCTION_TEMPLATE_ID = 'sim-function:00000000-0000-4000-8000-000000000001'
const DAYTONA_FUNCTION_SNAPSHOT_ID = '00000000-0000-4000-8000-000000000002'
function source(
kind: ConfigurationSource['kind'],
managedByCurrentCheckout: boolean,
values: Map<string, string> | null = new Map()
): ConfigurationSource {
return {
kind,
label: `${kind} source`,
location: `${kind} location`,
values,
managedByCurrentCheckout,
}
}
describe('resolveFeatureSetupDestination', () => {
it('refuses effective sources this checkout cannot safely update', () => {
expect(() => resolveFeatureSetupDestination([source('dev', false)])).toThrow(
/No effective configuration is safely writable/
)
expect(() => resolveFeatureSetupDestination([source('helm', false)])).toThrow(
/No effective configuration is safely writable/
)
})
it('refuses an unreadable managed source instead of claiming success', () => {
expect(() => resolveFeatureSetupDestination([source('compose', true, null)])).toThrow(
/effective environment could not be resolved/
)
})
})
describe('sandbox capability setup', () => {
it('requires immutable Function base references', () => {
expect(
validateCapabilityFieldInput(
SANDBOX_CAPABILITY,
'DAYTONA_FUNCTION_SNAPSHOT_ID',
DAYTONA_FUNCTION_SNAPSHOT_ID
)
).toBeUndefined()
expect(
validateCapabilityFieldInput(
SANDBOX_CAPABILITY,
'DAYTONA_FUNCTION_SNAPSHOT_ID',
'mothership-shell:v1'
)
).toContain('immutable Daytona snapshot ID')
expect(
validateCapabilityFieldInput(
SANDBOX_CAPABILITY,
'E2B_FUNCTION_TEMPLATE_ID',
E2B_FUNCTION_TEMPLATE_ID
)
).toBeUndefined()
expect(
validateCapabilityFieldInput(
SANDBOX_CAPABILITY,
'E2B_FUNCTION_TEMPLATE_ID',
'sim-function:latest'
)
).toContain('immutable E2B build reference')
})
})