Skip to content

Commit 4e5174f

Browse files
committed
test: remove skipped API key validation test from CLI integration tests
1 parent 82d4488 commit 4e5174f

File tree

1 file changed

+6
-54
lines changed

1 file changed

+6
-54
lines changed

tests/custom/integration/cli.test.ts

Lines changed: 6 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,26 @@ jest.setTimeout(40 * 1000); // 40 seconds
1515

1616
/**
1717
* Runs the Humanloop CLI as a child process, executing the TypeScript source directly.
18-
*
18+
*
1919
* This function is used in integration tests to verify CLI behavior. Instead of using
2020
* the compiled JavaScript file (dist/cli.js), it runs the TypeScript source (src/cli.ts)
2121
* directly using ts-node. This approach:
22-
*
22+
*
2323
* 1. Eliminates the need for a build step before running tests
2424
* 2. Ensures tests always run against the latest source code
2525
* 3. Maintains process isolation for proper CLI testing
26-
*
26+
*
2727
* Implementation details:
2828
* - Uses child_process.spawn to run the CLI in a separate process
2929
* - Uses npx to execute ts-node without requiring it as a dependency
3030
* - Captures stdout/stderr for assertion in tests
3131
* - Returns a promise that resolves with the command output and exit code
32-
*
32+
*
3333
* Environment setup:
3434
* - Modifies PATH to prioritize the project's node_modules/.bin
3535
* - This ensures we use the project's TypeScript version
3636
* - Preserves all other environment variables
37-
*
37+
*
3838
* Example usage:
3939
* ```typescript
4040
* const result = await runCli([
@@ -46,7 +46,7 @@ jest.setTimeout(40 * 1000); // 40 seconds
4646
* expect(result.exitCode).toBe(0);
4747
* expect(result.stdout).toContain("Pull completed");
4848
* ```
49-
*
49+
*
5050
* @param args - Array of command line arguments to pass to the CLI
5151
* @returns Promise resolving to an object containing:
5252
* - stdout: Standard output of the command
@@ -114,54 +114,6 @@ describe("CLI Integration Tests", () => {
114114
);
115115
});
116116

117-
/**
118-
* NOTE: This test is currently skipped due to issues with CLI environment isolation.
119-
*
120-
* The test attempts to verify behavior when no API key is available, but faces
121-
* challenges with how Node.js handles process execution during tests:
122-
*
123-
* 1. When executed via child_process.exec, the path to nonexistent env files
124-
* causes Node to return exit code 9 (SIGKILL) instead of the expected code 1
125-
* 2. Shell interpretation of arguments makes it difficult to reliably test this edge case
126-
*
127-
* If this functionality needs testing, consider:
128-
* - Using child_process.spawn for better argument handling
129-
* - Unit testing the API key validation logic directly
130-
* - Moving this test to a separate process with full environment isolation
131-
*
132-
* @see https://nodejs.org/api/child_process.html for more info on process execution
133-
*/
134-
test.skip("pull_without_api_key: should show error when no API key is available", async () => {
135-
// GIVEN a temporary directory and no API key
136-
const { tempDir, cleanup } = createTempDir("cli-no-api-key");
137-
138-
// Create a path to a file that definitely doesn't exist
139-
const nonExistentEnvFile = path.join(tempDir, "__DOES_NOT_EXIST__.env");
140-
141-
// WHEN running pull command without API key
142-
const originalApiKey = process.env.HUMANLOOP_API_KEY;
143-
delete process.env.HUMANLOOP_API_KEY;
144-
145-
const result = await runCli([
146-
"pull",
147-
"--local-files-directory",
148-
tempDir,
149-
"--env-file",
150-
`"${nonExistentEnvFile}"`,
151-
]);
152-
153-
// Restore API key
154-
process.env.HUMANLOOP_API_KEY = originalApiKey;
155-
156-
// THEN it should fail with appropriate error message
157-
expect(result.exitCode).not.toBe(0);
158-
expect(result.stderr + result.stdout).toContain(
159-
"Failed to load environment file",
160-
);
161-
162-
cleanup();
163-
});
164-
165117
test("pull_basic: should pull all files successfully", async () => {
166118
// GIVEN a base directory for pulled files
167119
const { tempDir, cleanup } = createTempDir("cli-basic-pull");

0 commit comments

Comments
 (0)