41 lines
1.1 KiB
Dart
41 lines
1.1 KiB
Dart
import "package:test/test.dart";
|
|
import "package:clawd_code/src/tools/bash_tool.dart";
|
|
|
|
|
|
void main() {
|
|
late BashTool tool;
|
|
|
|
setUp(() {
|
|
tool = BashTool();
|
|
});
|
|
|
|
group("BashTool", () {
|
|
test("runs a simple echo command", () async {
|
|
final result = await tool.execute({"command": "echo hello"});
|
|
expect(result.trim(), equals("hello"));
|
|
});
|
|
|
|
test("captures multi-line output", () async {
|
|
final result = await tool.execute({"command": "printf 'line1\nline2\n'"});
|
|
expect(result, contains("line1"));
|
|
expect(result, contains("line2"));
|
|
});
|
|
|
|
test("includes exit code on failure", () async {
|
|
final result = await tool.execute({"command": "exit 1"});
|
|
expect(result, contains("Exit code: 1"));
|
|
});
|
|
|
|
test("throws on empty command", () async {
|
|
expect(
|
|
() => tool.execute({"command": " "}),
|
|
throwsA(isA<ArgumentError>()),
|
|
);
|
|
});
|
|
|
|
test("captures stderr output", () async {
|
|
final result = await tool.execute({"command": "echo errormsg >&2"});
|
|
expect(result, contains("errormsg"));
|
|
});
|
|
});
|
|
}
|