Add new features and update configurations for improved functionality
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import "dart:io";
|
||||
|
||||
import "package:clawd_code/src/tools/grep_tool.dart";
|
||||
import "package:test/test.dart";
|
||||
|
||||
void main() {
|
||||
late Directory tempDir;
|
||||
late GrepTool tool;
|
||||
|
||||
setUp(() async {
|
||||
tempDir = await Directory.systemTemp.createTemp("grep_tool_test_");
|
||||
tool = GrepTool();
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
if (await tempDir.exists()) {
|
||||
await tempDir.delete(recursive: true);
|
||||
}
|
||||
});
|
||||
|
||||
group("GrepTool", () {
|
||||
test("searches a direct file path", () async {
|
||||
final file = File("${tempDir.path}/sample.txt");
|
||||
await file.writeAsString("alpha\nbeta\nalpha again\n");
|
||||
|
||||
final result = await tool.execute({
|
||||
"pattern": "alpha",
|
||||
"path": file.path,
|
||||
"output_mode": "content",
|
||||
});
|
||||
|
||||
expect(result, contains("sample.txt:1:alpha"));
|
||||
expect(result, contains("sample.txt:3:alpha again"));
|
||||
});
|
||||
|
||||
test("searches a directory path", () async {
|
||||
final nested = Directory("${tempDir.path}/nested");
|
||||
await nested.create(recursive: true);
|
||||
final file = File("${nested.path}/sample.txt");
|
||||
await file.writeAsString("needle\n");
|
||||
|
||||
final result = await tool.execute({
|
||||
"pattern": "needle",
|
||||
"path": tempDir.path,
|
||||
"output_mode": "files_with_matches",
|
||||
});
|
||||
|
||||
expect(result, contains("nested/sample.txt"));
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -42,7 +42,15 @@ void main() {
|
||||
|
||||
group("formatModelPricing", () {
|
||||
test("formats expected string", () {
|
||||
final result = formatModelPricing(costTier3_15);
|
||||
// Test with default cost tier
|
||||
final costs = ModelCosts(
|
||||
inputTokens: 3,
|
||||
outputTokens: 15,
|
||||
promptCacheWriteTokens: 3.75,
|
||||
promptCacheReadTokens: 0.3,
|
||||
provider: 'test',
|
||||
);
|
||||
final result = formatModelPricing(costs);
|
||||
expect(result, contains("3"));
|
||||
expect(result, contains("15"));
|
||||
expect(result, contains("Mtok"));
|
||||
|
||||
Reference in New Issue
Block a user