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 <[email protected]>
AuthorDate: Fri Nov 24 15:18:07 2023 +0800

    write capability check
    
    Signed-off-by: suyanhanx <[email protected]>
---
 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)
     })
   })

Reply via email to