summaryrefslogtreecommitdiff
path: root/integration-tests/write_file.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'integration-tests/write_file.test.ts')
-rw-r--r--integration-tests/write_file.test.ts88
1 files changed, 44 insertions, 44 deletions
diff --git a/integration-tests/write_file.test.ts b/integration-tests/write_file.test.ts
index 7809161e..3fe26af6 100644
--- a/integration-tests/write_file.test.ts
+++ b/integration-tests/write_file.test.ts
@@ -4,8 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
-import { test } from 'node:test';
-import { strict as assert } from 'assert';
+import { describe, it, expect } from 'vitest';
import {
TestRig,
createToolCallErrorMessage,
@@ -13,56 +12,57 @@ import {
validateModelOutput,
} from './test-helper.js';
-test('should be able to write a file', async () => {
- const rig = new TestRig();
- await rig.setup('should be able to write a file');
- const prompt = `show me an example of using the write tool. put a dad joke in dad.txt`;
+describe('write_file', () => {
+ it('should be able to write a file', async () => {
+ const rig = new TestRig();
+ await rig.setup('should be able to write a file');
+ const prompt = `show me an example of using the write tool. put a dad joke in dad.txt`;
- const result = await rig.run(prompt);
+ const result = await rig.run(prompt);
- const foundToolCall = await rig.waitForToolCall('write_file');
+ const foundToolCall = await rig.waitForToolCall('write_file');
- // Add debugging information
- if (!foundToolCall) {
- printDebugInfo(rig, result);
- }
+ // Add debugging information
+ if (!foundToolCall) {
+ printDebugInfo(rig, result);
+ }
- const allTools = rig.readToolLogs();
- assert.ok(
- foundToolCall,
- createToolCallErrorMessage(
- 'write_file',
- allTools.map((t) => t.toolRequest.name),
- result,
- ),
- );
+ const allTools = rig.readToolLogs();
+ expect(foundToolCall, 'Expected to find a write_file tool call').toBeTruthy(
+ createToolCallErrorMessage(
+ 'write_file',
+ allTools.map((t) => t.toolRequest.name),
+ result,
+ ),
+ );
- // Validate model output - will throw if no output, warn if missing expected content
- validateModelOutput(result, 'dad.txt', 'Write file test');
+ // Validate model output - will throw if no output, warn if missing expected content
+ validateModelOutput(result, 'dad.txt', 'Write file test');
- const newFilePath = 'dad.txt';
+ const newFilePath = 'dad.txt';
- const newFileContent = rig.readFile(newFilePath);
+ const newFileContent = rig.readFile(newFilePath);
- // Add debugging for file content
- if (newFileContent === '') {
- console.error('File was created but is empty');
- console.error(
- 'Tool calls:',
- rig.readToolLogs().map((t) => ({
- name: t.toolRequest.name,
- args: t.toolRequest.args,
- })),
- );
- }
+ // Add debugging for file content
+ if (newFileContent === '') {
+ console.error('File was created but is empty');
+ console.error(
+ 'Tool calls:',
+ rig.readToolLogs().map((t) => ({
+ name: t.toolRequest.name,
+ args: t.toolRequest.args,
+ })),
+ );
+ }
- assert.notEqual(newFileContent, '', 'Expected file to have content');
+ expect(newFileContent).not.toBe('');
- // Log success info if verbose
- if (process.env.VERBOSE === 'true') {
- console.log(
- 'File created successfully with content:',
- newFileContent.substring(0, 100) + '...',
- );
- }
+ // Log success info if verbose
+ if (process.env.VERBOSE === 'true') {
+ console.log(
+ 'File created successfully with content:',
+ newFileContent.substring(0, 100) + '...',
+ );
+ }
+ });
});