@xano/cli 1.0.4-beta.5 → 1.0.4-beta.8
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 +1 -0
- package/dist/commands/tenant/unit_test/run/index.d.ts +1 -0
- package/dist/commands/tenant/unit_test/run/index.js +7 -0
- package/dist/commands/tenant/unit_test/run_all/index.js +7 -3
- package/dist/commands/unit_test/run/index.d.ts +1 -0
- package/dist/commands/unit_test/run/index.js +8 -0
- package/dist/commands/unit_test/run_all/index.js +7 -3
- package/oclif.manifest.json +2870 -2851
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -326,6 +326,7 @@ xano unit_test list --branch dev --obj-type function
|
|
|
326
326
|
|
|
327
327
|
# Run a single unit test
|
|
328
328
|
xano unit_test run <unit_test_id>
|
|
329
|
+
xano unit_test run <unit_test_id> --branch dev # run the test from a specific branch
|
|
329
330
|
|
|
330
331
|
# Run all unit tests
|
|
331
332
|
xano unit_test run_all
|
|
@@ -6,6 +6,7 @@ export default class TenantUnitTestRun extends BaseCommand {
|
|
|
6
6
|
static description: string;
|
|
7
7
|
static examples: string[];
|
|
8
8
|
static flags: {
|
|
9
|
+
branch: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
10
|
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
11
|
tenant: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
12
|
workspace: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -17,6 +17,11 @@ Result: PASS
|
|
|
17
17
|
];
|
|
18
18
|
static flags = {
|
|
19
19
|
...BaseCommand.baseFlags,
|
|
20
|
+
branch: Flags.string({
|
|
21
|
+
char: 'b',
|
|
22
|
+
description: 'Branch the unit test belongs to (uses profile branch if not provided, then the live branch)',
|
|
23
|
+
required: false,
|
|
24
|
+
}),
|
|
20
25
|
output: Flags.string({
|
|
21
26
|
char: 'o',
|
|
22
27
|
default: 'summary',
|
|
@@ -43,12 +48,14 @@ Result: PASS
|
|
|
43
48
|
this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
|
|
44
49
|
}
|
|
45
50
|
const tenantName = encodeURIComponent(flags.tenant);
|
|
51
|
+
const branch = flags.branch ?? profile.branch;
|
|
46
52
|
const apiUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/tenant/${tenantName}/unit_test/${encodeURIComponent(args.unit_test_id)}/run`;
|
|
47
53
|
try {
|
|
48
54
|
if (flags.output === 'summary') {
|
|
49
55
|
this.log(`Running unit test ${args.unit_test_id}...`);
|
|
50
56
|
}
|
|
51
57
|
const response = await this.verboseFetch(apiUrl, {
|
|
58
|
+
body: JSON.stringify(branch ? { branch } : {}),
|
|
52
59
|
headers: {
|
|
53
60
|
accept: 'application/json',
|
|
54
61
|
Authorization: `Bearer ${profile.access_token}`,
|
|
@@ -18,7 +18,7 @@ Results: 4 passed, 1 failed
|
|
|
18
18
|
...BaseCommand.baseFlags,
|
|
19
19
|
branch: Flags.string({
|
|
20
20
|
char: 'b',
|
|
21
|
-
description: '
|
|
21
|
+
description: 'Branch to run tests from (uses profile branch if not provided, then the live branch)',
|
|
22
22
|
required: false,
|
|
23
23
|
}),
|
|
24
24
|
'obj-type': Flags.string({
|
|
@@ -53,11 +53,14 @@ Results: 4 passed, 1 failed
|
|
|
53
53
|
}
|
|
54
54
|
const tenantName = encodeURIComponent(flags.tenant);
|
|
55
55
|
const baseUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/tenant/${tenantName}/unit_test`;
|
|
56
|
+
// Resolve the branch once so the listed tests and the tests we run come
|
|
57
|
+
// from the same branch.
|
|
58
|
+
const branch = flags.branch ?? profile.branch;
|
|
56
59
|
try {
|
|
57
60
|
const listParams = new URLSearchParams();
|
|
58
61
|
listParams.set('per_page', '10000');
|
|
59
|
-
if (
|
|
60
|
-
listParams.set('branch',
|
|
62
|
+
if (branch)
|
|
63
|
+
listParams.set('branch', branch);
|
|
61
64
|
if (flags['obj-type'])
|
|
62
65
|
listParams.set('obj_type', flags['obj-type']);
|
|
63
66
|
const listResponse = await this.verboseFetch(`${baseUrl}?${listParams}`, {
|
|
@@ -94,6 +97,7 @@ Results: 4 passed, 1 failed
|
|
|
94
97
|
const runUrl = `${baseUrl}/${test.id}/run`;
|
|
95
98
|
try {
|
|
96
99
|
const runResponse = await this.verboseFetch(runUrl, {
|
|
100
|
+
body: JSON.stringify(branch ? { branch } : {}),
|
|
97
101
|
headers: {
|
|
98
102
|
accept: 'application/json',
|
|
99
103
|
Authorization: `Bearer ${profile.access_token}`,
|
|
@@ -6,6 +6,7 @@ export default class UnitTestRun extends BaseCommand {
|
|
|
6
6
|
static description: string;
|
|
7
7
|
static examples: string[];
|
|
8
8
|
static flags: {
|
|
9
|
+
branch: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
10
|
output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
11
|
workspace: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
12
|
config: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
@@ -14,9 +14,15 @@ Running unit test abc-123...
|
|
|
14
14
|
Result: PASS
|
|
15
15
|
`,
|
|
16
16
|
`$ xano unit-test run abc-123 -o json`,
|
|
17
|
+
`$ xano unit-test run abc-123 --branch dev`,
|
|
17
18
|
];
|
|
18
19
|
static flags = {
|
|
19
20
|
...BaseCommand.baseFlags,
|
|
21
|
+
branch: Flags.string({
|
|
22
|
+
char: 'b',
|
|
23
|
+
description: 'Branch the unit test belongs to (uses profile branch if not provided, then the live branch)',
|
|
24
|
+
required: false,
|
|
25
|
+
}),
|
|
20
26
|
output: Flags.string({
|
|
21
27
|
char: 'o',
|
|
22
28
|
default: 'summary',
|
|
@@ -37,12 +43,14 @@ Result: PASS
|
|
|
37
43
|
if (!workspaceId) {
|
|
38
44
|
this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
|
|
39
45
|
}
|
|
46
|
+
const branch = flags.branch ?? profile.branch;
|
|
40
47
|
const apiUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/unit_test/${args.unit_test_id}/run`;
|
|
41
48
|
try {
|
|
42
49
|
if (flags.output === 'summary') {
|
|
43
50
|
this.log(`Running unit test ${args.unit_test_id}...`);
|
|
44
51
|
}
|
|
45
52
|
const response = await this.verboseFetch(apiUrl, {
|
|
53
|
+
body: JSON.stringify(branch ? { branch } : {}),
|
|
46
54
|
headers: {
|
|
47
55
|
'accept': 'application/json',
|
|
48
56
|
'Authorization': `Bearer ${profile.access_token}`,
|
|
@@ -19,7 +19,7 @@ Results: 2 passed, 1 failed
|
|
|
19
19
|
...BaseCommand.baseFlags,
|
|
20
20
|
branch: Flags.string({
|
|
21
21
|
char: 'b',
|
|
22
|
-
description: '
|
|
22
|
+
description: 'Branch to run tests from (uses profile branch if not provided, then the live branch)',
|
|
23
23
|
required: false,
|
|
24
24
|
}),
|
|
25
25
|
'obj-type': Flags.string({
|
|
@@ -48,12 +48,15 @@ Results: 2 passed, 1 failed
|
|
|
48
48
|
this.error('No workspace ID provided. Use --workspace flag or set one in your profile.');
|
|
49
49
|
}
|
|
50
50
|
const baseUrl = `${profile.instance_origin}/api:meta/workspace/${workspaceId}/unit_test`;
|
|
51
|
+
// Resolve the branch once so the listed tests and the tests we run come
|
|
52
|
+
// from the same branch.
|
|
53
|
+
const branch = flags.branch ?? profile.branch;
|
|
51
54
|
try {
|
|
52
55
|
// Step 1: List all unit tests
|
|
53
56
|
const listParams = new URLSearchParams();
|
|
54
57
|
listParams.set('per_page', '10000');
|
|
55
|
-
if (
|
|
56
|
-
listParams.set('branch',
|
|
58
|
+
if (branch) {
|
|
59
|
+
listParams.set('branch', branch);
|
|
57
60
|
}
|
|
58
61
|
if (flags['obj-type']) {
|
|
59
62
|
listParams.set('obj_type', flags['obj-type']);
|
|
@@ -93,6 +96,7 @@ Results: 2 passed, 1 failed
|
|
|
93
96
|
const runUrl = `${baseUrl}/${test.id}/run`;
|
|
94
97
|
try {
|
|
95
98
|
const runResponse = await this.verboseFetch(runUrl, {
|
|
99
|
+
body: JSON.stringify(branch ? { branch } : {}),
|
|
96
100
|
headers: {
|
|
97
101
|
accept: 'application/json',
|
|
98
102
|
Authorization: `Bearer ${profile.access_token}`,
|