|
1 | 1 | import { describe, expect, it } from 'vitest' |
2 | 2 |
|
3 | | -import { generateOptions, generateThresholds } from './options' |
| 3 | +import { |
| 4 | + generateCloudOptions, |
| 5 | + generateOptions, |
| 6 | + generateThresholds, |
| 7 | +} from './options' |
4 | 8 | import { |
5 | 9 | LoadProfileExecutorOptions, |
| 10 | + LoadZoneData, |
6 | 11 | TestOptions, |
7 | 12 | Threshold, |
8 | 13 | } from '@/types/testOptions' |
9 | 14 | import { createThreshold } from '@/test/factories/threshold' |
| 15 | +import { createLoadZone } from '@/test/factories/loadZones' |
10 | 16 |
|
11 | 17 | describe('Code generation - options', () => { |
12 | 18 | it('should generate load profile for shared-iterations executor', () => { |
@@ -118,3 +124,41 @@ describe('Code generation - thresholds', () => { |
118 | 124 | expect(generateThresholds(thresholds)).toEqual(expectedResult) |
119 | 125 | }) |
120 | 126 | }) |
| 127 | + |
| 128 | +describe('Code generation - cloud options', () => { |
| 129 | + it('should generate load zones correctly', () => { |
| 130 | + const loadZones: LoadZoneData = { |
| 131 | + distribution: 'even', |
| 132 | + zones: [ |
| 133 | + createLoadZone({ loadZone: 'amazon:us:columbus', percent: 50 }), |
| 134 | + createLoadZone({ loadZone: 'amazon:br:sao paulo', percent: 50 }), |
| 135 | + ], |
| 136 | + } |
| 137 | + |
| 138 | + const expectedResult = { |
| 139 | + cloud: { |
| 140 | + distribution: { |
| 141 | + "'amazon:us:columbus'": { |
| 142 | + loadZone: 'amazon:us:columbus', |
| 143 | + percent: 50, |
| 144 | + }, |
| 145 | + "'amazon:br:sao paulo'": { |
| 146 | + loadZone: 'amazon:br:sao paulo', |
| 147 | + percent: 50, |
| 148 | + }, |
| 149 | + }, |
| 150 | + }, |
| 151 | + } |
| 152 | + |
| 153 | + expect(generateCloudOptions({ loadZones })).toEqual(expectedResult) |
| 154 | + }) |
| 155 | + |
| 156 | + it('should not generate cloud object when load zones are not selected', () => { |
| 157 | + const loadZones: LoadZoneData = { |
| 158 | + distribution: 'even', |
| 159 | + zones: [], |
| 160 | + } |
| 161 | + |
| 162 | + expect(generateCloudOptions({ loadZones })).toEqual({}) |
| 163 | + }) |
| 164 | +}) |
0 commit comments