-
Notifications
You must be signed in to change notification settings - Fork 860
Add optional depth parameter to SDK file listing methods. #649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
db5089c
* update envd spec & generate for js-sdk
0div aeed7eb
Merge branch 'main' into recursive-files-list-in-the-sdk-e2b-1902_2
0div 8e9ea77
* create Docker image with all the pinned deps needed to codegen
0div 66d213a
Merge branch 'main' into make-codegen-deterministic-for-sdks-e2b-1969
0div 181cd51
:wMerge branch 'main' of https://github.com/e2b-dev/E2B into recursiv…
0div 7f3bff9
Merge branch 'make-codegen-deterministic-for-sdks-e2b-1969' into recu…
0div 6355298
Merge branch 'main' of https://github.com/e2b-dev/E2B into recursive-…
0div 5bc4622
add depth param to file list in python-sdk sync and async and update …
0div 14347a3
updated codegen
0div fe3a2f6
remove dev test file
0div f57fdeb
update js-sdk tests to loop and test -1 depth
0div 427822c
update python-sdk tests to loop and assert throw for depth out of range
0div 4c2c99f
Merge branch 'main' of https://github.com/e2b-dev/E2B into recursive-…
0div d9349f6
extend FilesystemOpts to include optional depth
0div 13612cb
Merge branch 'main' of https://github.com/e2b-dev/E2B into recursive-…
0div 8796734
js-sdk: make depth seperate param; better error message; update tests
0div d489712
Merge branch 'main' of https://github.com/e2b-dev/E2B into recursive-…
0div c588a36
extend FilesystemListOpts
mishushakov c6230c1
Merge branch 'main' into recursive-files-list-in-the-sdk-e2b-1902_2
0div 7fbccd5
split files list test (js)
mishushakov b831a64
split files.list tests (py)
mishushakov 0a7ae10
rm next test
0div 838d694
python-sdk: return InvalidArgument for negative depth and update tests
0div 2cfc52e
Merge branch 'main' of https://github.com/e2b-dev/E2B into recursive-…
0div 9e0e769
add full paths in python-sdk list tests
0div c984a46
update depthp param validation and tests in js-sdk
0div 765e054
Merge branch 'main' of https://github.com/e2b-dev/E2B into recursive-…
0div ea21f65
add missing argument error and tests
0div 0495b8a
[boyscouting] remove unintented api_ref dir in root folder
0div 24a2af4
Merge branch 'main' of https://github.com/e2b-dev/E2B into recursive-…
0div bedb5d6
distinguish between path and name and fix js-sdk tests
0div 71d0a3f
remove logs from test
0div e2aed07
add type, name and path assertiosn in python-sdk tests
0div c70317d
fix js-sdk test 502 from cleanup function
0div d7f859c
Merge branch 'main' into recursive-files-list-in-the-sdk-e2b-1902_2
0div File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,23 +1,121 @@ | ||
| import { assert } from 'vitest' | ||
| import { assert, onTestFinished } from 'vitest' | ||
|
|
||
| import { sandboxTest } from '../../setup.js' | ||
| import { sandboxTest, wait } from '../../setup.js' | ||
|
|
||
| const parentDirName = 'test_directory' | ||
|
|
||
| sandboxTest('list directory', async ({ sandbox }) => { | ||
| const dirName = 'test_directory4' | ||
| const homeDirName = '/home/user' | ||
| await sandbox.files.makeDir(parentDirName) | ||
| await sandbox.files.makeDir(`${parentDirName}/subdir1`) | ||
| await sandbox.files.makeDir(`${parentDirName}/subdir2`) | ||
| await sandbox.files.makeDir(`${parentDirName}/subdir1/subdir1_1`) | ||
| await sandbox.files.makeDir(`${parentDirName}/subdir1/subdir1_2`) | ||
| await sandbox.files.makeDir(`${parentDirName}/subdir2/subdir2_1`) | ||
| await sandbox.files.makeDir(`${parentDirName}/subdir2/subdir2_2`) | ||
|
0div marked this conversation as resolved.
|
||
| await sandbox.files.write(`${parentDirName}/file1.txt`, 'Hello, world!') | ||
|
|
||
| await sandbox.files.makeDir(dirName) | ||
| const testCases = [ | ||
| { | ||
| test_name: 'default depth (1)', | ||
| depth: undefined, | ||
| expectedLen: 3, | ||
| expectedFileNames: ['file1.txt', 'subdir1', 'subdir2'], | ||
| expectedFileTypes: ['file', 'dir', 'dir'], | ||
| expectedFilePaths: [ | ||
| `${homeDirName}/${parentDirName}/file1.txt`, | ||
| `${homeDirName}/${parentDirName}/subdir1`, | ||
| `${homeDirName}/${parentDirName}/subdir2`, | ||
| ], | ||
| }, | ||
| { | ||
| test_name: 'explicit depth 1', | ||
| depth: 1, | ||
| expectedLen: 3, | ||
| expectedFileNames: ['file1.txt', 'subdir1', 'subdir2'], | ||
| expectedFileTypes: ['file', 'dir', 'dir'], | ||
| expectedFilePaths: [ | ||
| `${homeDirName}/${parentDirName}/file1.txt`, | ||
| `${homeDirName}/${parentDirName}/subdir1`, | ||
| `${homeDirName}/${parentDirName}/subdir2`, | ||
| ], | ||
| }, | ||
| { | ||
| test_name: 'explicit depth 2', | ||
| depth: 2, | ||
| expectedLen: 7, | ||
| expectedFileTypes: ['file', 'dir', 'dir', 'dir', 'dir', 'dir', 'dir'], | ||
| expectedFileNames: [ | ||
| 'file1.txt', | ||
| 'subdir1', | ||
| 'subdir1_1', | ||
| 'subdir1_2', | ||
| 'subdir2', | ||
| 'subdir2_1', | ||
| 'subdir2_2', | ||
| ], | ||
| expectedFilePaths: [ | ||
| `${homeDirName}/${parentDirName}/file1.txt`, | ||
| `${homeDirName}/${parentDirName}/subdir1`, | ||
| `${homeDirName}/${parentDirName}/subdir1/subdir1_1`, | ||
| `${homeDirName}/${parentDirName}/subdir1/subdir1_2`, | ||
| `${homeDirName}/${parentDirName}/subdir2`, | ||
| `${homeDirName}/${parentDirName}/subdir2/subdir2_1`, | ||
| `${homeDirName}/${parentDirName}/subdir2/subdir2_2`, | ||
| ], | ||
| }, | ||
| { | ||
| test_name: 'explicit depth 3 (should be the same as depth 2)', | ||
| depth: 3, | ||
| expectedLen: 7, | ||
| expectedFileTypes: ['file', 'dir', 'dir', 'dir', 'dir', 'dir', 'dir'], | ||
| expectedFileNames: [ | ||
| 'file1.txt', | ||
| 'subdir1', | ||
| 'subdir1_1', | ||
| 'subdir1_2', | ||
| 'subdir2', | ||
| 'subdir2_1', | ||
| 'subdir2_2', | ||
| ], | ||
| expectedFilePaths: [ | ||
| `${homeDirName}/${parentDirName}/file1.txt`, | ||
| `${homeDirName}/${parentDirName}/subdir1`, | ||
| `${homeDirName}/${parentDirName}/subdir1/subdir1_1`, | ||
| `${homeDirName}/${parentDirName}/subdir1/subdir1_2`, | ||
| `${homeDirName}/${parentDirName}/subdir2`, | ||
| `${homeDirName}/${parentDirName}/subdir2/subdir2_1`, | ||
| `${homeDirName}/${parentDirName}/subdir2/subdir2_2`, | ||
| ], | ||
| }, | ||
| ] | ||
|
|
||
| const files = await sandbox.files.list(dirName) | ||
| assert.equal(files.length, 0) | ||
| for (const testCase of testCases) { | ||
| const files = await sandbox.files.list( | ||
| parentDirName, | ||
| testCase.depth !== undefined ? { depth: testCase.depth } : undefined | ||
| ) | ||
| assert.equal(files.length, testCase.expectedLen) | ||
|
|
||
| await sandbox.files.write('test_directory4/test_file', 'test') | ||
| for (let i = 0; i < testCase.expectedFilePaths.length; i++) { | ||
| assert.equal(files[i].type, testCase.expectedFileTypes[i]) | ||
| assert.equal(files[i].name, testCase.expectedFileNames[i]) | ||
| assert.equal(files[i].path, testCase.expectedFilePaths[i]) | ||
| } | ||
| } | ||
| }) | ||
|
|
||
| const files1 = await sandbox.files.list(dirName) | ||
| assert.equal(files1.length, 1) | ||
| assert.equal(files1[0].name, 'test_file') | ||
| assert.equal(files1[0].type, 'file') | ||
| assert.equal(files1[0].path, `/home/user/${dirName}/test_file`) | ||
| sandboxTest('list directory with invalid depth', async ({ sandbox }) => { | ||
| await sandbox.files.makeDir(parentDirName) | ||
|
|
||
| const exists = await sandbox.files.exists(dirName) | ||
| assert.isTrue(exists) | ||
| try { | ||
| await sandbox.files.list(parentDirName, { depth: -1 }) | ||
| assert.fail('Expected error but none was thrown') | ||
| } catch (err) { | ||
| const expectedErrorMessage = 'depth should be at least one' | ||
| assert.ok( | ||
| err.message.includes(expectedErrorMessage), | ||
| `expected error message to include "${expectedErrorMessage}"` | ||
| ) | ||
| } | ||
| }) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.