-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add unit test for MaxTargetVolumeLimit
- Loading branch information
1 parent
849d720
commit 278af3c
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import LimitCheckerImpl from '../LimitCheckerImpl'; | ||
import { options } from '../logger'; | ||
options.enabled = false; | ||
|
||
describe('LimitCheckerImpl', () => { | ||
test('MaxTargetVolumeLimit - violate', () => { | ||
const config = { maxTargetVolumePercent: 50 }; | ||
const ps = {}; | ||
const analysisResult = { availableVolume: 1.0, targetVolume: 0.7 }; | ||
const checker = new LimitCheckerImpl({ config }, ps, analysisResult, analysisResult, false); | ||
checker.limits = checker.limits.filter(limit => limit.constructor.name === 'MaxTargetVolumeLimit'); | ||
const result = checker.check(); | ||
expect(result.success).toBe(false); | ||
expect(result.reason).toBe('Too large Volume'); | ||
}); | ||
|
||
test('MaxTargetVolumeLimit - pass', () => { | ||
const config = { maxTargetVolumePercent: 50 }; | ||
const ps = {}; | ||
const analysisResult = { availableVolume: 1.0, targetVolume: 0.3 }; | ||
const checker = new LimitCheckerImpl({ config }, ps, analysisResult, analysisResult, false); | ||
checker.limits = checker.limits.filter(limit => limit.constructor.name === 'MaxTargetVolumeLimit'); | ||
const result = checker.check(); | ||
expect(result.success).toBe(true); | ||
expect(result.reason).toBe(''); | ||
}); | ||
|
||
test('MaxTargetVolumeLimit - undefined', () => { | ||
const config = { maxTargetVolumePercent: undefined }; | ||
const ps = {}; | ||
const analysisResult = { availableVolume: 1.0, targetVolume: 0.3 }; | ||
const checker = new LimitCheckerImpl({ config }, ps, analysisResult, analysisResult, false); | ||
checker.limits = checker.limits.filter(limit => limit.constructor.name === 'MaxTargetVolumeLimit'); | ||
const result = checker.check(); | ||
expect(result.success).toBe(true); | ||
expect(result.reason).toBe(''); | ||
}); | ||
}); |