neonctl 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +126 -0
- package/commands/auth.js +4 -0
- package/commands/branches.js +40 -41
- package/commands/branches.test.js +85 -0
- package/commands/databases.js +54 -0
- package/commands/databases.test.js +52 -0
- package/commands/endpoints.js +86 -0
- package/commands/endpoints.test.js +85 -0
- package/commands/index.js +3 -1
- package/commands/projects.js +26 -18
- package/commands/projects.test.js +46 -0
- package/commands/users.js +3 -2
- package/config.js +2 -1
- package/env.js +3 -0
- package/index.js +12 -1
- package/package.json +10 -3
- package/parameters.gen.js +123 -0
- package/test_utils.js +75 -0
- package/utils.js +9 -0
- package/writer.js +59 -50
- package/writer.test.js +86 -0
package/writer.test.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { Writable } from 'node:stream';
|
|
2
|
+
import { describe, it, expect } from '@jest/globals';
|
|
3
|
+
import { writer } from './writer.js';
|
|
4
|
+
class MockWritable extends Writable {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this._data = [];
|
|
8
|
+
}
|
|
9
|
+
get data() {
|
|
10
|
+
return this._data.map((chunk) => chunk.toString()).join('');
|
|
11
|
+
}
|
|
12
|
+
_write(chunk) {
|
|
13
|
+
this._data.push(chunk);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
describe('writer', () => {
|
|
17
|
+
describe('outputs yaml', () => {
|
|
18
|
+
it('outputs single data', () => {
|
|
19
|
+
const stream = new MockWritable();
|
|
20
|
+
const out = writer({ output: 'yaml', out: stream });
|
|
21
|
+
out.end({ foo: 'bar' }, { fields: ['foo'] });
|
|
22
|
+
expect(stream.data).toMatchSnapshot();
|
|
23
|
+
});
|
|
24
|
+
it('outputs single data with title', () => {
|
|
25
|
+
const stream = new MockWritable();
|
|
26
|
+
const out = writer({ output: 'yaml', out: stream });
|
|
27
|
+
out.end({ foo: 'bar' }, { fields: ['foo'], title: 'baz' });
|
|
28
|
+
expect(stream.data).toMatchSnapshot();
|
|
29
|
+
});
|
|
30
|
+
it('outputs multiple data', () => {
|
|
31
|
+
const stream = new MockWritable();
|
|
32
|
+
const out = writer({ output: 'yaml', out: stream });
|
|
33
|
+
out
|
|
34
|
+
.write({ foo: 'bar' }, { fields: ['foo'], title: 'T1' })
|
|
35
|
+
.write({ baz: 'xyz' }, { fields: ['baz'], title: 'T2' })
|
|
36
|
+
.end();
|
|
37
|
+
expect(stream.data).toMatchSnapshot();
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
describe('outputs json', () => {
|
|
41
|
+
it('outputs single data', () => {
|
|
42
|
+
const stream = new MockWritable();
|
|
43
|
+
const out = writer({ output: 'json', out: stream });
|
|
44
|
+
out.end({ foo: 'bar' }, { fields: ['foo'] });
|
|
45
|
+
expect(stream.data).toMatchSnapshot();
|
|
46
|
+
});
|
|
47
|
+
it('outputs single data with title', () => {
|
|
48
|
+
const stream = new MockWritable();
|
|
49
|
+
const out = writer({ output: 'json', out: stream });
|
|
50
|
+
out.end({ foo: 'bar' }, { fields: ['foo'], title: 'baz' });
|
|
51
|
+
expect(stream.data).toMatchSnapshot();
|
|
52
|
+
});
|
|
53
|
+
it('outputs multiple data', () => {
|
|
54
|
+
const stream = new MockWritable();
|
|
55
|
+
const out = writer({ output: 'json', out: stream });
|
|
56
|
+
out
|
|
57
|
+
.write({ foo: 'bar' }, { fields: ['foo'], title: 'T1' })
|
|
58
|
+
.write({ baz: 'xyz' }, { fields: ['baz'], title: 'T2' })
|
|
59
|
+
.end();
|
|
60
|
+
expect(stream.data).toMatchSnapshot();
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
describe('outputs table', () => {
|
|
64
|
+
it('outputs single data', () => {
|
|
65
|
+
const stream = new MockWritable();
|
|
66
|
+
const out = writer({ output: 'table', out: stream });
|
|
67
|
+
out.end({ foo: 'bar', extra: 'extra' }, { fields: ['foo'] });
|
|
68
|
+
expect(stream.data).toMatchSnapshot();
|
|
69
|
+
});
|
|
70
|
+
it('outputs single data with title', () => {
|
|
71
|
+
const stream = new MockWritable();
|
|
72
|
+
const out = writer({ output: 'table', out: stream });
|
|
73
|
+
out.end({ foo: 'bar', extra: 'extra' }, { fields: ['foo'], title: 'baz' });
|
|
74
|
+
expect(stream.data).toMatchSnapshot();
|
|
75
|
+
});
|
|
76
|
+
it('outputs multiple data', () => {
|
|
77
|
+
const stream = new MockWritable();
|
|
78
|
+
const out = writer({ output: 'table', out: stream });
|
|
79
|
+
out
|
|
80
|
+
.write({ foo: 'bar', extra: 'extra' }, { fields: ['foo'], title: 'T1' })
|
|
81
|
+
.write({ baz: 'xyz', extra: 'extra' }, { fields: ['baz'], title: 'T2' })
|
|
82
|
+
.end();
|
|
83
|
+
expect(stream.data).toMatchSnapshot();
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
});
|