mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 03:20:12 +08:00
feat: add checkfiles into Condition
This commit is contained in:
1 parent
d612b2d6af
commit
65ad72223b
4 files changed
+36
-8
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { test, expect } from '@jest/globals'
|
||||
import { IFileExistenceChecker, FileType, FileInput } from '../src/types.js'
|
||||
import { checkFiles } from '../src/condition/FileMatcher.js'
|
||||
import { Condition } from '../src/condition/Condition.js'
|
||||
|
||||
class MockFileChecker implements IFileExistenceChecker {
|
||||
private files: FileInput[] = [
|
||||
@@ -90,3 +91,17 @@ test('file matcher', async () => {
|
||||
])
|
||||
).toBe(false)
|
||||
})
|
||||
|
||||
test('condition with file matcher', async () => {
|
||||
const checker = new MockFileChecker()
|
||||
const condition = new Condition({
|
||||
files: [
|
||||
{
|
||||
path: '/home/user/hello.txt',
|
||||
type: FileType.FILE,
|
||||
exists: true,
|
||||
},
|
||||
],
|
||||
})
|
||||
expect(await condition.check(checker)).toBe(true)
|
||||
})
|
||||
Reference in new issue
Block a user