You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by su...@apache.org on 2023/11/24 07:18:43 UTC
(incubator-opendal) 03/03: write capability check
This is an automated email from the ASF dual-hosted git repository.
suyanhanx pushed a commit to branch nodejs-stream
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
commit 50746586e01ac5dc4ce9ba4cd5b56d339a868ec3
Author: suyanhanx <su...@gmail.com>
AuthorDate: Fri Nov 24 15:18:07 2023 +0800
write capability check
Signed-off-by: suyanhanx <su...@gmail.com>
---
bindings/nodejs/tests/suites/sync.suite.mjs | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/bindings/nodejs/tests/suites/sync.suite.mjs b/bindings/nodejs/tests/suites/sync.suite.mjs
index 732f8e5b2..6710dc289 100644
--- a/bindings/nodejs/tests/suites/sync.suite.mjs
+++ b/bindings/nodejs/tests/suites/sync.suite.mjs
@@ -23,24 +23,28 @@ import fs from 'node:fs'
import path from 'node:path'
import { WriterStream } from '../../index.js'
-export function run(operator) {
+export function run(op) {
test('sync stat not exist files', () => {
const filename = `random_file_${randomUUID()}`
try {
- operator.statSync(filename)
+ op.statSync(filename)
} catch (error) {
assert.include(error.message, 'NotFound')
}
})
test('blocking writer stream', async () => {
+ if (!op.capability().write) {
+ return
+ }
+
const filename = `random_file_${randomUUID()}`
const r = fs.createReadStream(path.resolve(__dirname, '../fixtures/random.txt'))
- const w = new WriterStream(operator, filename)
+ const w = new WriterStream(op, filename)
r.pipe(w)
w.on('finish', () => {
- const t = operator.statSync(filename)
+ const t = op.statSync(filename)
assert.equal(t.contentLength, fs.statSync(path.resolve(__dirname, '../fixtures/random.txt')).size)
})
})