]> khamidou — GitHub mirrors - electron.git/commitdiff
spec: asar: fs.open
authorCheng Zhao <zcbenz@gmail.com>
Mon, 29 Sep 2014 08:05:19 +0000 (16:05 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Mon, 29 Sep 2014 08:05:19 +0000 (16:05 +0800)
spec/asar-spec.coffee

index 996924a1068251db02ce528bb182ae8c04ca745e..f129c0d83e07d85b40495ac15775ee2a89433748 100644 (file)
@@ -214,3 +214,18 @@ describe 'asar package', ->
         stats = fs.readdir p, (err, stats) ->
           assert.equal err.code, 'ENOENT'
           done()
+
+    describe 'fs.openSync', ->
+      it 'opens a normal/linked/under-linked-directory file', ->
+        for file in ['file1', 'link1', path.join('link2', 'file1')]
+          p = path.join fixtures, 'asar', 'a.asar', file
+          fd = fs.openSync p, 'r'
+          buffer = new Buffer(6)
+          fs.readSync fd, buffer, 0, 6, 0
+          assert.equal String(buffer), 'file1\n'
+          fs.closeSync fd
+
+      it 'throws ENOENT error when can not find file', ->
+        p = path.join fixtures, 'asar', 'a.asar', 'not-exist'
+        throws = -> fs.openSync p
+        assert.throws throws, /ENOENT/