-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update dependencies * add test for source function * update dependencies * add more adapter tests * add test for common functions * add test for uniq path segments
- Loading branch information
1 parent
61b560f
commit 1af2566
Showing
18 changed files
with
505 additions
and
241 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,31 @@ | ||
import { describe, test, expect } from 'vitest'; | ||
import { AlreadyExistsException, NotFoundException } from './exceptions'; | ||
import { MEMORY_TYPE } from './definitions'; | ||
|
||
describe('exceptions', () => { | ||
test('NotFoundException with root', () => { | ||
const error = new NotFoundException('test', { $type: MEMORY_TYPE.ROOT, content: [] }); | ||
expect(error.message).toBe('Could not find test'); | ||
expect(error.last).toEqual({ $type: MEMORY_TYPE.ROOT, content: [] }); | ||
expect(error.depth).toBe(0); | ||
}); | ||
|
||
test('NotFoundException with directory', () => { | ||
const error = new NotFoundException('test', { $type: MEMORY_TYPE.DIRECTORY, name:'test', content: [] }); | ||
expect(error.message).toBe('Could not find test'); | ||
expect(error.last).toEqual({ $type: MEMORY_TYPE.DIRECTORY, name: 'test', content: [] }); | ||
expect(error.depth).toBe(0); | ||
}); | ||
|
||
test('AlreadyExistsException with root', () => { | ||
const error = new AlreadyExistsException('test', { $type: MEMORY_TYPE.ROOT, content: [] }); | ||
expect(error.message).toBe('Already exists test'); | ||
expect(error.ref).toEqual({ $type: MEMORY_TYPE.ROOT, content: [] }); | ||
}); | ||
|
||
test('AlreadyExistsException with directory', () => { | ||
const error = new AlreadyExistsException('test', { $type: MEMORY_TYPE.DIRECTORY, name:'test', content: [] }); | ||
expect(error.message).toBe('Already exists test'); | ||
expect(error.ref).toEqual({ $type: MEMORY_TYPE.DIRECTORY, name: 'test', content: [] }); | ||
}); | ||
}); |
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
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,4 @@ | ||
import { testSource } from '@loom-io/interface-tests'; | ||
import InMemorySourceAdapter from '../src/exports/lib'; | ||
|
||
testSource('memory://', InMemorySourceAdapter()); |
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
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,20 @@ | ||
import { describe, test, expect } from 'vitest'; | ||
import { isMinioException } from './typechecks.js'; | ||
import { } from 'minio'; | ||
|
||
class MinioLikeException extends Error{ | ||
code: string; | ||
message: string; | ||
} | ||
|
||
|
||
describe('typechecks', () => { | ||
test('isMinioException', () => { | ||
expect(isMinioException(new Error('test'))).toBe(false); | ||
expect(isMinioException({})).toBe(false); | ||
expect(isMinioException({ code: 'test' })).toBe(false); | ||
expect(isMinioException({ message: 'test' })).toBe(false); | ||
expect(isMinioException({ code: 'test', message: 'test' })).toBe(false); | ||
expect(isMinioException(new MinioLikeException('test'))).toBe(true); | ||
}); | ||
}); |
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,16 @@ | ||
import { testSource } from '@loom-io/interface-tests'; | ||
import S3MinioSourceAdapter from '../src/exports/lib'; | ||
|
||
const s3config = { | ||
endPoint: 'play.min.io', | ||
port: 9000, | ||
useSSL: true, | ||
accessKey: 'Q3AM3UQ867SPQQA43P2F', | ||
secretKey: 'zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG', | ||
}; | ||
|
||
|
||
testSource('s3://', S3MinioSourceAdapter(undefined, { | ||
bucket: 'test-bucket', | ||
...s3config | ||
})); |
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
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,26 @@ | ||
import { testSource } from '@loom-io/interface-tests'; | ||
import FilesystemSourceAdapter from '../src/exports/lib'; | ||
import { describe, expect, test } from 'vitest'; | ||
import { source } from '../src/core/source'; | ||
import { LoomFile } from '@loom-io/core/internal'; | ||
|
||
|
||
|
||
testSource('file://', FilesystemSourceAdapter()); | ||
|
||
describe('Detail source test for node-fs adapter', () => { | ||
test('should return a LoomFile for a existing file path', async () => { | ||
const file = await source('adapters/node-fs/src/core/source.ts'); | ||
expect(file).toBeDefined(); | ||
expect(file).toBeInstanceOf(LoomFile); | ||
expect(file).toHaveProperty('path', 'adapters/node-fs/src/core/source.ts'); | ||
}); | ||
|
||
test('should return a Directory for a existing directory path', async () => { | ||
const dir = await source('adapters/node-fs/src/core'); | ||
expect(dir).toBeDefined(); | ||
expect(dir).not.toBeInstanceOf(LoomFile); | ||
expect(dir).toHaveProperty('path', 'adapters/node-fs/src/core'); | ||
}); | ||
|
||
}); |
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
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
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
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
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
Oops, something went wrong.