-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathci_error.js
More file actions
41 lines (38 loc) · 1.63 KB
/
ci_error.js
File metadata and controls
41 lines (38 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright © 2017, 2024 IBM Corp. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/* global describe it */
const assert = require('assert');
const { mkdtemp, open, rm } = require('fs/promises');
const u = require('./citestutils.js');
describe('Write error tests', function() {
it('calls callback with error set when stream is not writeable', async function() {
u.setTimeout(this, 10);
// Make a temp directory
const dirname = await mkdtemp('test_backup_');
const filename = dirname + '/test.backup';
// Create a backup file
const file = await open(filename, 'w');
// Use a read stream instead of a write stream
const backupStream = await file.createReadStream();
const params = { useApi: true };
// try to do backup and check err was set in callback
return assert.rejects(u.testBackup(params, 'animaldb', backupStream), { name: 'TypeError', message: 'dest.write is not a function' })
.finally(async () => {
// Destroy the read stream we didn't use
backupStream.destroy();
// cleanup temp dir
await rm(dirname, { recursive: true });
});
});
});