neonctl 2.22.0 → 2.23.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 +242 -16
- package/analytics.js +5 -2
- package/commands/branches.js +9 -1
- package/commands/checkout.js +249 -0
- package/commands/connection_string.js +15 -2
- package/commands/data_api.js +286 -0
- package/commands/functions.js +277 -0
- package/commands/index.js +12 -0
- package/commands/link.js +667 -0
- package/commands/neon_auth.js +1013 -0
- package/commands/projects.js +9 -1
- package/commands/psql.js +62 -0
- package/commands/set_context.js +7 -2
- package/context.js +86 -14
- package/functions_api.js +44 -0
- package/index.js +3 -0
- package/package.json +60 -51
- package/psql/cli.js +51 -0
- package/psql/command/cmd_cond.js +437 -0
- package/psql/command/cmd_connect.js +815 -0
- package/psql/command/cmd_copy.js +1025 -0
- package/psql/command/cmd_describe.js +1810 -0
- package/psql/command/cmd_format.js +909 -0
- package/psql/command/cmd_io.js +2187 -0
- package/psql/command/cmd_lo.js +385 -0
- package/psql/command/cmd_meta.js +970 -0
- package/psql/command/cmd_misc.js +187 -0
- package/psql/command/cmd_pipeline.js +1141 -0
- package/psql/command/cmd_restrict.js +171 -0
- package/psql/command/cmd_show.js +751 -0
- package/psql/command/dispatch.js +343 -0
- package/psql/command/inputQueue.js +42 -0
- package/psql/command/shared.js +71 -0
- package/psql/complete/filenames.js +139 -0
- package/psql/complete/index.js +104 -0
- package/psql/complete/matcher.js +314 -0
- package/psql/complete/psqlVars.js +247 -0
- package/psql/complete/queries.js +491 -0
- package/psql/complete/rules.js +2387 -0
- package/psql/core/common.js +1250 -0
- package/psql/core/help.js +576 -0
- package/psql/core/mainloop.js +1353 -0
- package/psql/core/prompt.js +437 -0
- package/psql/core/settings.js +684 -0
- package/psql/core/sqlHelp.js +1066 -0
- package/psql/core/startup.js +840 -0
- package/psql/core/syncVars.js +116 -0
- package/psql/core/variables.js +287 -0
- package/psql/describe/formatters.js +1277 -0
- package/psql/describe/processNamePattern.js +270 -0
- package/psql/describe/queries.js +2373 -0
- package/psql/describe/versionGate.js +43 -0
- package/psql/index.js +2005 -0
- package/psql/io/history.js +299 -0
- package/psql/io/input.js +120 -0
- package/psql/io/lineEditor/buffer.js +323 -0
- package/psql/io/lineEditor/complete.js +227 -0
- package/psql/io/lineEditor/filename.js +159 -0
- package/psql/io/lineEditor/index.js +891 -0
- package/psql/io/lineEditor/keymap.js +738 -0
- package/psql/io/lineEditor/vt100.js +363 -0
- package/psql/io/pgpass.js +202 -0
- package/psql/io/pgservice.js +194 -0
- package/psql/io/psqlrc.js +422 -0
- package/psql/print/aligned.js +1756 -0
- package/psql/print/asciidoc.js +248 -0
- package/psql/print/crosstab.js +460 -0
- package/psql/print/csv.js +92 -0
- package/psql/print/html.js +258 -0
- package/psql/print/json.js +96 -0
- package/psql/print/latex.js +396 -0
- package/psql/print/pager.js +265 -0
- package/psql/print/troff.js +258 -0
- package/psql/print/unaligned.js +118 -0
- package/psql/print/units.js +135 -0
- package/psql/scanner/slash.js +513 -0
- package/psql/scanner/sql.js +910 -0
- package/psql/scanner/stringutils.js +390 -0
- package/psql/types/backslash.js +1 -0
- package/psql/types/connection.js +1 -0
- package/psql/types/index.js +7 -0
- package/psql/types/printer.js +1 -0
- package/psql/types/repl.js +1 -0
- package/psql/types/scanner.js +24 -0
- package/psql/types/settings.js +1 -0
- package/psql/types/variables.js +1 -0
- package/psql/wire/connection.js +2844 -0
- package/psql/wire/copy.js +108 -0
- package/psql/wire/notify.js +59 -0
- package/psql/wire/pipeline.js +519 -0
- package/psql/wire/protocol.js +466 -0
- package/psql/wire/sasl.js +296 -0
- package/psql/wire/tls.js +596 -0
- package/test_utils/fixtures.js +1 -0
- package/utils/enrichers.js +18 -1
- package/utils/esbuild.js +147 -0
- package/utils/middlewares.js +1 -1
- package/utils/psql.js +107 -11
- package/utils/zip.js +4 -0
- package/writer.js +1 -1
- package/commands/auth.test.js +0 -211
- package/commands/branches.test.js +0 -460
- package/commands/connection_string.test.js +0 -196
- package/commands/databases.test.js +0 -39
- package/commands/help.test.js +0 -9
- package/commands/init.test.js +0 -56
- package/commands/ip_allow.test.js +0 -59
- package/commands/operations.test.js +0 -7
- package/commands/orgs.test.js +0 -7
- package/commands/projects.test.js +0 -144
- package/commands/roles.test.js +0 -37
- package/commands/set_context.test.js +0 -159
- package/commands/vpc_endpoints.test.js +0 -69
- package/env.test.js +0 -55
- package/utils/formats.test.js +0 -32
- package/writer.test.js +0 -104
package/commands/init.test.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, test, vi } from 'vitest';
|
|
2
|
-
// Mock dependencies that require package.json
|
|
3
|
-
vi.mock('../analytics.js', () => ({
|
|
4
|
-
sendError: vi.fn(),
|
|
5
|
-
trackEvent: vi.fn(),
|
|
6
|
-
closeAnalytics: vi.fn(),
|
|
7
|
-
}));
|
|
8
|
-
vi.mock('../log.js', () => ({
|
|
9
|
-
log: { error: vi.fn(), info: vi.fn(), warning: vi.fn(), debug: vi.fn() },
|
|
10
|
-
}));
|
|
11
|
-
// Mock neon-init
|
|
12
|
-
vi.mock('neon-init', () => ({
|
|
13
|
-
init: vi.fn().mockResolvedValue(undefined),
|
|
14
|
-
}));
|
|
15
|
-
describe('init', () => {
|
|
16
|
-
const exitSpy = vi
|
|
17
|
-
.spyOn(process, 'exit')
|
|
18
|
-
.mockImplementation((() => undefined));
|
|
19
|
-
afterEach(() => {
|
|
20
|
-
vi.clearAllMocks();
|
|
21
|
-
});
|
|
22
|
-
test('should call neon-init with no options when agent is omitted', async () => {
|
|
23
|
-
const { handler } = await import('./init.js');
|
|
24
|
-
const { init } = await import('neon-init');
|
|
25
|
-
await handler({});
|
|
26
|
-
expect(init).toHaveBeenCalledTimes(1);
|
|
27
|
-
expect(init).toHaveBeenCalledWith(undefined);
|
|
28
|
-
});
|
|
29
|
-
test('should call neon-init with { agent: "Cursor" } when --agent cursor', async () => {
|
|
30
|
-
const { handler } = await import('./init.js');
|
|
31
|
-
const { init } = await import('neon-init');
|
|
32
|
-
await handler({ agent: 'cursor' });
|
|
33
|
-
expect(init).toHaveBeenCalledWith({ agent: 'Cursor' });
|
|
34
|
-
});
|
|
35
|
-
test('should call neon-init with { agent: "VS Code" } when --agent copilot', async () => {
|
|
36
|
-
const { handler } = await import('./init.js');
|
|
37
|
-
const { init } = await import('neon-init');
|
|
38
|
-
await handler({ agent: 'copilot' });
|
|
39
|
-
expect(init).toHaveBeenCalledWith({ agent: 'VS Code' });
|
|
40
|
-
});
|
|
41
|
-
test('should call neon-init with { agent: "Claude CLI" } when --agent claude', async () => {
|
|
42
|
-
const { handler } = await import('./init.js');
|
|
43
|
-
const { init } = await import('neon-init');
|
|
44
|
-
await handler({ agent: 'claude' });
|
|
45
|
-
expect(init).toHaveBeenCalledWith({ agent: 'Claude CLI' });
|
|
46
|
-
});
|
|
47
|
-
test('should log error and exit 1 when --agent is invalid', async () => {
|
|
48
|
-
const { handler } = await import('./init.js');
|
|
49
|
-
const { init } = await import('neon-init');
|
|
50
|
-
const { log } = await import('../log.js');
|
|
51
|
-
await handler({ agent: 'invalid-agent' });
|
|
52
|
-
expect(init).not.toHaveBeenCalled();
|
|
53
|
-
expect(log.error).toHaveBeenCalledWith('Invalid --agent value: "invalid-agent". Supported: cursor, copilot, claude');
|
|
54
|
-
expect(exitSpy).toHaveBeenCalledWith(1);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { describe } from 'vitest';
|
|
2
|
-
import { test } from '../test_utils/fixtures';
|
|
3
|
-
describe('ip-allow', () => {
|
|
4
|
-
test('list IP allow', async ({ testCliCommand }) => {
|
|
5
|
-
await testCliCommand(['ip-allow', 'list', '--project-id', 'test']);
|
|
6
|
-
});
|
|
7
|
-
test('list IP Allow with single-project', async ({ testCliCommand }) => {
|
|
8
|
-
await testCliCommand(['ip-allow', 'list'], {
|
|
9
|
-
mockDir: 'single_project',
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
test('Add IP allow - Error', async ({ testCliCommand }) => {
|
|
13
|
-
await testCliCommand(['ip-allow', 'add', '--projectId', 'test'], {
|
|
14
|
-
code: 1,
|
|
15
|
-
stderr: `ERROR: Enter individual IP addresses, define ranges with a dash, or use CIDR notation for more flexibility.
|
|
16
|
-
Example: neonctl ip-allow add 192.168.1.1, 192.168.1.20-192.168.1.50, 192.168.1.0/24 --project-id <id>`,
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
test('Add IP allow - Protected', async ({ testCliCommand }) => {
|
|
20
|
-
await testCliCommand([
|
|
21
|
-
'ip-allow',
|
|
22
|
-
'add',
|
|
23
|
-
'127.0.0.1',
|
|
24
|
-
'192.168.10.1-192.168.10.15',
|
|
25
|
-
'--protected-only',
|
|
26
|
-
'--project-id',
|
|
27
|
-
'test',
|
|
28
|
-
]);
|
|
29
|
-
});
|
|
30
|
-
test('Remove IP allow - Error', async ({ testCliCommand }) => {
|
|
31
|
-
await testCliCommand(['ip-allow', 'remove', '--project-id', 'test'], {
|
|
32
|
-
code: 1,
|
|
33
|
-
stderr: `ERROR: Remove individual IP addresses and ranges. Example: neonctl ip-allow remove 192.168.1.1 --project-id <id>`,
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
test('Remove IP allow', async ({ testCliCommand }) => {
|
|
37
|
-
await testCliCommand([
|
|
38
|
-
'ip-allow',
|
|
39
|
-
'remove',
|
|
40
|
-
'192.168.1.1',
|
|
41
|
-
'--project-id',
|
|
42
|
-
'test',
|
|
43
|
-
]);
|
|
44
|
-
});
|
|
45
|
-
test('Reset IP allow', async ({ testCliCommand }) => {
|
|
46
|
-
await testCliCommand(['ip-allow', 'reset', '--project-id', 'test'], {
|
|
47
|
-
stderr: `INFO: The IP allowlist has been reset. All databases on project "test_project" are now exposed to the internet`,
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
test('Reset IP allow to new list', async ({ testCliCommand }) => {
|
|
51
|
-
await testCliCommand([
|
|
52
|
-
'ip-allow',
|
|
53
|
-
'reset',
|
|
54
|
-
'192.168.2.2',
|
|
55
|
-
'--project-id',
|
|
56
|
-
'test',
|
|
57
|
-
]);
|
|
58
|
-
});
|
|
59
|
-
});
|
package/commands/orgs.test.js
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { describe, expect } from 'vitest';
|
|
2
|
-
import { readFileSync, rmSync } from 'node:fs';
|
|
3
|
-
import { tmpdir } from 'node:os';
|
|
4
|
-
import { join } from 'node:path';
|
|
5
|
-
import { test } from '../test_utils/fixtures';
|
|
6
|
-
describe('projects', () => {
|
|
7
|
-
test('list', async ({ testCliCommand }) => {
|
|
8
|
-
await testCliCommand(['projects', 'list']);
|
|
9
|
-
});
|
|
10
|
-
test('list with org id', async ({ testCliCommand }) => {
|
|
11
|
-
await testCliCommand(['projects', 'list', '--org-id', 'org-2']);
|
|
12
|
-
});
|
|
13
|
-
test('list recoverable projects', async ({ testCliCommand }) => {
|
|
14
|
-
await testCliCommand(['projects', 'list', '--recoverable-only']);
|
|
15
|
-
});
|
|
16
|
-
test('create', async ({ testCliCommand }) => {
|
|
17
|
-
await testCliCommand(['projects', 'create', '--name', 'test_project']);
|
|
18
|
-
});
|
|
19
|
-
test('create with hipaa flag', async ({ testCliCommand }) => {
|
|
20
|
-
await testCliCommand([
|
|
21
|
-
'projects',
|
|
22
|
-
'create',
|
|
23
|
-
'--name',
|
|
24
|
-
'test_project',
|
|
25
|
-
'--hipaa',
|
|
26
|
-
]);
|
|
27
|
-
});
|
|
28
|
-
test('create with org id', async ({ testCliCommand }) => {
|
|
29
|
-
await testCliCommand([
|
|
30
|
-
'projects',
|
|
31
|
-
'create',
|
|
32
|
-
'--name',
|
|
33
|
-
'test_project',
|
|
34
|
-
'--org-id',
|
|
35
|
-
'org-2',
|
|
36
|
-
]);
|
|
37
|
-
});
|
|
38
|
-
test('create with database and role', async ({ testCliCommand }) => {
|
|
39
|
-
await testCliCommand([
|
|
40
|
-
'projects',
|
|
41
|
-
'create',
|
|
42
|
-
'--name',
|
|
43
|
-
'test_project',
|
|
44
|
-
'--database',
|
|
45
|
-
'test_db',
|
|
46
|
-
'--role',
|
|
47
|
-
'test_role',
|
|
48
|
-
]);
|
|
49
|
-
});
|
|
50
|
-
test('create and connect with psql', async ({ testCliCommand }) => {
|
|
51
|
-
await testCliCommand([
|
|
52
|
-
'projects',
|
|
53
|
-
'create',
|
|
54
|
-
'--name',
|
|
55
|
-
'test_project',
|
|
56
|
-
'--psql',
|
|
57
|
-
]);
|
|
58
|
-
});
|
|
59
|
-
test('create and connect with psql and psql args', async ({ testCliCommand, }) => {
|
|
60
|
-
await testCliCommand([
|
|
61
|
-
'projects',
|
|
62
|
-
'create',
|
|
63
|
-
'--name',
|
|
64
|
-
'test_project',
|
|
65
|
-
'--psql',
|
|
66
|
-
'--',
|
|
67
|
-
'-c',
|
|
68
|
-
'SELECT 1',
|
|
69
|
-
]);
|
|
70
|
-
});
|
|
71
|
-
test('create project with setting the context', async ({ testCliCommand, }) => {
|
|
72
|
-
const CONTEXT_FILE = join(tmpdir(), `neon_project_create_ctx_${Date.now()}`);
|
|
73
|
-
await testCliCommand([
|
|
74
|
-
'projects',
|
|
75
|
-
'create',
|
|
76
|
-
'--name',
|
|
77
|
-
'test_project',
|
|
78
|
-
'--context-file',
|
|
79
|
-
CONTEXT_FILE,
|
|
80
|
-
'--set-context',
|
|
81
|
-
]);
|
|
82
|
-
expect(readFileSync(CONTEXT_FILE, 'utf-8')).toContain('new-project-123456');
|
|
83
|
-
rmSync(CONTEXT_FILE);
|
|
84
|
-
});
|
|
85
|
-
test('create project with default fixed size CU', async ({ testCliCommand, }) => {
|
|
86
|
-
await testCliCommand([
|
|
87
|
-
'projects',
|
|
88
|
-
'create',
|
|
89
|
-
'--name',
|
|
90
|
-
'test_project_with_fixed_cu',
|
|
91
|
-
'--cu',
|
|
92
|
-
'2',
|
|
93
|
-
]);
|
|
94
|
-
});
|
|
95
|
-
test('create project with default autoscaled CU', async ({ testCliCommand, }) => {
|
|
96
|
-
await testCliCommand([
|
|
97
|
-
'projects',
|
|
98
|
-
'create',
|
|
99
|
-
'--name',
|
|
100
|
-
'test_project_with_autoscaling',
|
|
101
|
-
'--cu',
|
|
102
|
-
'0.5-2',
|
|
103
|
-
]);
|
|
104
|
-
});
|
|
105
|
-
test('delete', async ({ testCliCommand }) => {
|
|
106
|
-
await testCliCommand(['projects', 'delete', 'test']);
|
|
107
|
-
});
|
|
108
|
-
test('recover deleted project', async ({ testCliCommand }) => {
|
|
109
|
-
await testCliCommand(['projects', 'recover', 'test']);
|
|
110
|
-
});
|
|
111
|
-
test('update name', async ({ testCliCommand }) => {
|
|
112
|
-
await testCliCommand([
|
|
113
|
-
'projects',
|
|
114
|
-
'update',
|
|
115
|
-
'test',
|
|
116
|
-
'--name',
|
|
117
|
-
'test_project_new_name',
|
|
118
|
-
]);
|
|
119
|
-
});
|
|
120
|
-
test('update hipaa flag', async ({ testCliCommand }) => {
|
|
121
|
-
await testCliCommand(['projects', 'update', 'test', '--hipaa']);
|
|
122
|
-
});
|
|
123
|
-
test('update project with default fixed size CU', async ({ testCliCommand, }) => {
|
|
124
|
-
await testCliCommand([
|
|
125
|
-
'projects',
|
|
126
|
-
'update',
|
|
127
|
-
'test_project_with_fixed_cu',
|
|
128
|
-
'--cu',
|
|
129
|
-
'2',
|
|
130
|
-
]);
|
|
131
|
-
});
|
|
132
|
-
test('update project with default autoscaled CU', async ({ testCliCommand, }) => {
|
|
133
|
-
await testCliCommand([
|
|
134
|
-
'projects',
|
|
135
|
-
'update',
|
|
136
|
-
'test_project_with_autoscaling',
|
|
137
|
-
'--cu',
|
|
138
|
-
'0.5-2',
|
|
139
|
-
]);
|
|
140
|
-
});
|
|
141
|
-
test('get', async ({ testCliCommand }) => {
|
|
142
|
-
await testCliCommand(['projects', 'get', 'test']);
|
|
143
|
-
});
|
|
144
|
-
});
|
package/commands/roles.test.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { describe } from 'vitest';
|
|
2
|
-
import { test } from '../test_utils/fixtures';
|
|
3
|
-
describe('roles', () => {
|
|
4
|
-
test('list', async ({ testCliCommand }) => {
|
|
5
|
-
await testCliCommand([
|
|
6
|
-
'roles',
|
|
7
|
-
'list',
|
|
8
|
-
'--project-id',
|
|
9
|
-
'test',
|
|
10
|
-
'--branch',
|
|
11
|
-
'test_branch',
|
|
12
|
-
]);
|
|
13
|
-
});
|
|
14
|
-
test('create', async ({ testCliCommand }) => {
|
|
15
|
-
await testCliCommand([
|
|
16
|
-
'roles',
|
|
17
|
-
'create',
|
|
18
|
-
'--project-id',
|
|
19
|
-
'test',
|
|
20
|
-
'--branch',
|
|
21
|
-
'test_branch',
|
|
22
|
-
'--name',
|
|
23
|
-
'test_role',
|
|
24
|
-
]);
|
|
25
|
-
});
|
|
26
|
-
test('delete', async ({ testCliCommand }) => {
|
|
27
|
-
await testCliCommand([
|
|
28
|
-
'roles',
|
|
29
|
-
'delete',
|
|
30
|
-
'test_role',
|
|
31
|
-
'--project-id',
|
|
32
|
-
'test',
|
|
33
|
-
'--branch',
|
|
34
|
-
'test_branch',
|
|
35
|
-
]);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { tmpdir } from 'node:os';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { rmSync, writeFileSync, readFileSync } from 'node:fs';
|
|
4
|
-
import { describe, expect } from 'vitest';
|
|
5
|
-
import { test as originalTest } from '../test_utils/fixtures';
|
|
6
|
-
const CONTEXT_FILE = join(tmpdir(), `neon_${Date.now()}`);
|
|
7
|
-
const test = originalTest.extend({
|
|
8
|
-
// eslint-disable-next-line no-empty-pattern
|
|
9
|
-
cleanupFile: async ({}, use) => {
|
|
10
|
-
let writtenFilename;
|
|
11
|
-
await use((name) => (writtenFilename = name));
|
|
12
|
-
if (writtenFilename) {
|
|
13
|
-
rmSync(writtenFilename);
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
writeFile: async ({ cleanupFile }, use) => {
|
|
17
|
-
await use((name, content) => {
|
|
18
|
-
writeFileSync(name, JSON.stringify(content));
|
|
19
|
-
cleanupFile(name);
|
|
20
|
-
});
|
|
21
|
-
},
|
|
22
|
-
readFile: async ({ cleanupFile }, use) => {
|
|
23
|
-
await use((name) => {
|
|
24
|
-
const content = readFileSync(name, 'utf-8');
|
|
25
|
-
cleanupFile(name);
|
|
26
|
-
return content;
|
|
27
|
-
});
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
describe('set_context', () => {
|
|
31
|
-
describe('should set the context to project', () => {
|
|
32
|
-
test('set-context', async ({ testCliCommand, readFile }) => {
|
|
33
|
-
await testCliCommand([
|
|
34
|
-
'set-context',
|
|
35
|
-
'--project-id',
|
|
36
|
-
'test',
|
|
37
|
-
'--context-file',
|
|
38
|
-
CONTEXT_FILE,
|
|
39
|
-
]);
|
|
40
|
-
expect(readFile(CONTEXT_FILE)).toMatchSnapshot();
|
|
41
|
-
});
|
|
42
|
-
test('list branches selecting project from the context', async ({ testCliCommand, writeFile, }) => {
|
|
43
|
-
writeFile(CONTEXT_FILE, {
|
|
44
|
-
projectId: 'test',
|
|
45
|
-
});
|
|
46
|
-
await testCliCommand([
|
|
47
|
-
'branches',
|
|
48
|
-
'list',
|
|
49
|
-
'--context-file',
|
|
50
|
-
CONTEXT_FILE,
|
|
51
|
-
]);
|
|
52
|
-
});
|
|
53
|
-
const overrideContextFile = join(tmpdir(), `neon_override_ctx_${Date.now()}`);
|
|
54
|
-
test('get project id overrides context set project', async ({ testCliCommand, writeFile, }) => {
|
|
55
|
-
writeFile(overrideContextFile, {
|
|
56
|
-
projectId: 'new-project id',
|
|
57
|
-
});
|
|
58
|
-
await testCliCommand([
|
|
59
|
-
'project',
|
|
60
|
-
'get',
|
|
61
|
-
'project-id-123',
|
|
62
|
-
'--context-file',
|
|
63
|
-
overrideContextFile,
|
|
64
|
-
]);
|
|
65
|
-
});
|
|
66
|
-
test('set the branchId and projectId is from context', async ({ testCliCommand, writeFile, }) => {
|
|
67
|
-
writeFile(overrideContextFile, {
|
|
68
|
-
projectId: 'test',
|
|
69
|
-
branchId: 'test_branch',
|
|
70
|
-
});
|
|
71
|
-
await testCliCommand([
|
|
72
|
-
'databases',
|
|
73
|
-
'list',
|
|
74
|
-
'--context-file',
|
|
75
|
-
overrideContextFile,
|
|
76
|
-
]);
|
|
77
|
-
});
|
|
78
|
-
test('set the branchId and projectId is from context', async ({ testCliCommand, writeFile, }) => {
|
|
79
|
-
writeFile(overrideContextFile, {
|
|
80
|
-
projectId: 'project-id-123',
|
|
81
|
-
branchId: 'test_branch',
|
|
82
|
-
});
|
|
83
|
-
await testCliCommand([
|
|
84
|
-
'databases',
|
|
85
|
-
'list',
|
|
86
|
-
'--project-id',
|
|
87
|
-
'test',
|
|
88
|
-
'--context-file',
|
|
89
|
-
overrideContextFile,
|
|
90
|
-
], {
|
|
91
|
-
code: 1,
|
|
92
|
-
stderr: 'ERROR: Not Found',
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
describe('should set the context to organization', () => {
|
|
97
|
-
test('set-context', async ({ testCliCommand, readFile }) => {
|
|
98
|
-
await testCliCommand([
|
|
99
|
-
'set-context',
|
|
100
|
-
'--org-id',
|
|
101
|
-
'org-2',
|
|
102
|
-
'--context-file',
|
|
103
|
-
CONTEXT_FILE,
|
|
104
|
-
]);
|
|
105
|
-
expect(readFile(CONTEXT_FILE)).toMatchSnapshot();
|
|
106
|
-
});
|
|
107
|
-
test('list projects selecting organization from the context', async ({ testCliCommand, writeFile, }) => {
|
|
108
|
-
writeFile(CONTEXT_FILE, {
|
|
109
|
-
orgId: 'org-2',
|
|
110
|
-
});
|
|
111
|
-
await testCliCommand([
|
|
112
|
-
'projects',
|
|
113
|
-
'list',
|
|
114
|
-
'--context-file',
|
|
115
|
-
CONTEXT_FILE,
|
|
116
|
-
]);
|
|
117
|
-
});
|
|
118
|
-
test('list projects with explicit org id overrides context', async ({ testCliCommand, writeFile, }) => {
|
|
119
|
-
writeFile(CONTEXT_FILE, {
|
|
120
|
-
orgId: 'org-2',
|
|
121
|
-
});
|
|
122
|
-
await testCliCommand([
|
|
123
|
-
'project',
|
|
124
|
-
'list',
|
|
125
|
-
'--org-id',
|
|
126
|
-
'org-3',
|
|
127
|
-
'--context-file',
|
|
128
|
-
CONTEXT_FILE,
|
|
129
|
-
]);
|
|
130
|
-
});
|
|
131
|
-
test('create projects selecting organization from the context', async ({ testCliCommand, writeFile, }) => {
|
|
132
|
-
writeFile(CONTEXT_FILE, {
|
|
133
|
-
orgId: 'org-2',
|
|
134
|
-
});
|
|
135
|
-
await testCliCommand([
|
|
136
|
-
'projects',
|
|
137
|
-
'create',
|
|
138
|
-
'--name',
|
|
139
|
-
'test_project',
|
|
140
|
-
'--context-file',
|
|
141
|
-
CONTEXT_FILE,
|
|
142
|
-
]);
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
describe('can set the context to project and organization at the same time', () => {
|
|
146
|
-
test('set-context', async ({ testCliCommand, readFile }) => {
|
|
147
|
-
await testCliCommand([
|
|
148
|
-
'set-context',
|
|
149
|
-
'--project-id',
|
|
150
|
-
'test_project',
|
|
151
|
-
'--org-id',
|
|
152
|
-
'org-2',
|
|
153
|
-
'--context-file',
|
|
154
|
-
CONTEXT_FILE,
|
|
155
|
-
]);
|
|
156
|
-
expect(readFile(CONTEXT_FILE)).toMatchSnapshot();
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
});
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { describe } from 'vitest';
|
|
2
|
-
import { test } from '../test_utils/fixtures';
|
|
3
|
-
describe('vpc-endpoints', () => {
|
|
4
|
-
test('list org VPC endpoints', async ({ testCliCommand }) => {
|
|
5
|
-
await testCliCommand(['vpc', 'endpoint', 'list', '--org-id', '1', '--region-id', 'test'], { mockDir: 'single_org' });
|
|
6
|
-
});
|
|
7
|
-
test('list org VPC endpoints implicit org', async ({ testCliCommand }) => {
|
|
8
|
-
await testCliCommand(['vpc', 'endpoint', 'list', '--region-id', 'test'], {
|
|
9
|
-
mockDir: 'single_org',
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
test('update org VPC endpoint', async ({ testCliCommand }) => {
|
|
13
|
-
await testCliCommand([
|
|
14
|
-
'vpc',
|
|
15
|
-
'endpoint',
|
|
16
|
-
'update',
|
|
17
|
-
'vpc-test',
|
|
18
|
-
'--label',
|
|
19
|
-
'newlabel',
|
|
20
|
-
'--region-id',
|
|
21
|
-
'test',
|
|
22
|
-
], { mockDir: 'single_org' });
|
|
23
|
-
});
|
|
24
|
-
test('delete org VPC endpoint', async ({ testCliCommand }) => {
|
|
25
|
-
await testCliCommand(['vpc', 'endpoint', 'remove', 'vpc-test', '--region-id', 'test'], { mockDir: 'single_org' });
|
|
26
|
-
});
|
|
27
|
-
test('get org VPC endpoint status', async ({ testCliCommand }) => {
|
|
28
|
-
await testCliCommand(['vpc', 'endpoint', 'status', 'vpc-test', '--region-id', 'test'], { mockDir: 'single_org' });
|
|
29
|
-
});
|
|
30
|
-
test('set org VPC endpoint in azure', async ({ testCliCommand }) => {
|
|
31
|
-
await testCliCommand([
|
|
32
|
-
'vpc',
|
|
33
|
-
'endpoint',
|
|
34
|
-
'update',
|
|
35
|
-
'vpc-test',
|
|
36
|
-
'--label',
|
|
37
|
-
'newlabel',
|
|
38
|
-
'--region-id',
|
|
39
|
-
'azure-test',
|
|
40
|
-
], {
|
|
41
|
-
mockDir: 'single_org',
|
|
42
|
-
stderr: 'INFO: VPC endpoint configuration is not supported for Azure regions',
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
test('list project VPC endpoint restrictions', async ({ testCliCommand }) => {
|
|
46
|
-
await testCliCommand([
|
|
47
|
-
'vpc',
|
|
48
|
-
'project',
|
|
49
|
-
'list',
|
|
50
|
-
'--region-id',
|
|
51
|
-
'test',
|
|
52
|
-
'--project-id',
|
|
53
|
-
'test-project-123456',
|
|
54
|
-
], { mockDir: 'single_org' });
|
|
55
|
-
});
|
|
56
|
-
test('list project VPC endpoint restrictions with implicit project', async ({ testCliCommand, }) => {
|
|
57
|
-
await testCliCommand(['vpc', 'project', 'list', '--region-id', 'test'], {
|
|
58
|
-
mockDir: 'single_org',
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
test('set project VPC endpoint restrictions', async ({ testCliCommand }) => {
|
|
62
|
-
await testCliCommand(['vpc', 'project', 'update', 'vpc-test', '--label', 'newlabel'], { mockDir: 'single_org' });
|
|
63
|
-
});
|
|
64
|
-
test('delete project VPC endpoint restrictions', async ({ testCliCommand, }) => {
|
|
65
|
-
await testCliCommand(['vpc', 'project', 'remove', 'vpc-test'], {
|
|
66
|
-
mockDir: 'single_org',
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
});
|
package/env.test.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { getGithubEnvVars } from './env';
|
|
3
|
-
describe('getGithubEnvVars', () => {
|
|
4
|
-
it('success all keys', () => {
|
|
5
|
-
const env = {
|
|
6
|
-
GITHUB_ACTION_PATH: '1',
|
|
7
|
-
GITHUB_REPOSITORY: '2',
|
|
8
|
-
GITHUB_RUN_ID: '3',
|
|
9
|
-
GITHUB_RUN_NUMBER: '4',
|
|
10
|
-
GITHUB_SERVER_URL: '5',
|
|
11
|
-
GITHUB_WORKFLOW_REF: '6',
|
|
12
|
-
RUNNER_ARCH: '7',
|
|
13
|
-
RUNNER_ENVIRONMENT: '8',
|
|
14
|
-
RUNNER_OS: '9',
|
|
15
|
-
unrelated: 'unrelated',
|
|
16
|
-
};
|
|
17
|
-
const ret = {
|
|
18
|
-
GITHUB_ACTION_PATH: '1',
|
|
19
|
-
GITHUB_REPOSITORY: '2',
|
|
20
|
-
GITHUB_RUN_ID: '3',
|
|
21
|
-
GITHUB_RUN_NUMBER: '4',
|
|
22
|
-
GITHUB_SERVER_URL: '5',
|
|
23
|
-
GITHUB_WORKFLOW_REF: '6',
|
|
24
|
-
RUNNER_ARCH: '7',
|
|
25
|
-
RUNNER_ENVIRONMENT: '8',
|
|
26
|
-
RUNNER_OS: '9',
|
|
27
|
-
};
|
|
28
|
-
expect(getGithubEnvVars(env)).toEqual(ret);
|
|
29
|
-
});
|
|
30
|
-
it('empty all keys', () => {
|
|
31
|
-
expect(getGithubEnvVars({})).toEqual({});
|
|
32
|
-
});
|
|
33
|
-
it('action path', () => {
|
|
34
|
-
expect(getGithubEnvVars({
|
|
35
|
-
GITHUB_ACTION_PATH: '/home/runner/work/_actions/neondatabase/create-branch-action/v5',
|
|
36
|
-
})).toEqual({
|
|
37
|
-
GITHUB_ACTION_PATH: 'neondatabase/create-branch-action/v5',
|
|
38
|
-
});
|
|
39
|
-
expect(getGithubEnvVars({
|
|
40
|
-
GITHUB_ACTION_PATH: '/home/runner/actions-runner/_work/actions/neondatabase/create-branch-action/v5',
|
|
41
|
-
})).toEqual({
|
|
42
|
-
GITHUB_ACTION_PATH: 'neondatabase/create-branch-action/v5',
|
|
43
|
-
});
|
|
44
|
-
expect(getGithubEnvVars({
|
|
45
|
-
GITHUB_ACTION_PATH: 'C:\\b\\_actions\\neondatabase\\create-branch-action\\v5',
|
|
46
|
-
})).toEqual({
|
|
47
|
-
GITHUB_ACTION_PATH: 'C:\\b\\_actions\\neondatabase\\create-branch-action\\v5',
|
|
48
|
-
});
|
|
49
|
-
expect(getGithubEnvVars({
|
|
50
|
-
GITHUB_ACTION_PATH: '/home/runner/work/app/app/./.github/actions/custom-action',
|
|
51
|
-
})).toEqual({
|
|
52
|
-
GITHUB_ACTION_PATH: 'custom-action',
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
});
|
package/utils/formats.test.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { test, describe, expect } from 'vitest';
|
|
2
|
-
import { looksLikeBranchId, looksLikeLSN, looksLikeTimestamp } from './formats';
|
|
3
|
-
describe('branch formats', () => {
|
|
4
|
-
test('branch name', () => {
|
|
5
|
-
expect(looksLikeBranchId('master')).toBe(false);
|
|
6
|
-
});
|
|
7
|
-
test('initial short', () => {
|
|
8
|
-
expect(looksLikeBranchId('br-flower-sunshine-123456')).toBe(true);
|
|
9
|
-
});
|
|
10
|
-
test('update 1, longer version', () => {
|
|
11
|
-
expect(looksLikeBranchId('br-flower-sunshine-12345678')).toBe(true);
|
|
12
|
-
});
|
|
13
|
-
test('update 2, includes region', () => {
|
|
14
|
-
expect(looksLikeBranchId('br-bold-recipe-a13oexw7')).toBe(true);
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
describe('timestamp formats', () => {
|
|
18
|
-
test('valid', () => {
|
|
19
|
-
expect(looksLikeTimestamp('2021-03-13T19:47:33.000Z')).toBe(true);
|
|
20
|
-
});
|
|
21
|
-
test('invalid', () => {
|
|
22
|
-
expect(looksLikeTimestamp('branch_name')).toBe(false);
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
describe('LSN formats', () => {
|
|
26
|
-
test('valid', () => {
|
|
27
|
-
expect(looksLikeLSN('0/1F56000')).toBe(true);
|
|
28
|
-
});
|
|
29
|
-
test('invalid', () => {
|
|
30
|
-
expect(looksLikeLSN('branch_name')).toBe(false);
|
|
31
|
-
});
|
|
32
|
-
});
|