Add scripttest-based integration tests (#59)
- Complete test coverage for all major bd commands: blocked, close, create, dep (add/remove/tree), export, help, import, init, list, quickstart, ready, show, stats, update, version - Test data files validate command behavior and output - Enables automated testing of full CLI workflows
This commit is contained in:
26
cmd/bd/scripttest_test.go
Normal file
26
cmd/bd/scripttest_test.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os/exec"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"rsc.io/script"
|
||||
"rsc.io/script/scripttest"
|
||||
)
|
||||
|
||||
func TestScripts(t *testing.T) {
|
||||
// Build the bd binary
|
||||
exe := t.TempDir() + "/bd"
|
||||
if err := exec.Command("go", "build", "-o", exe, ".").Run(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Create minimal engine with default commands plus bd
|
||||
engine := script.NewEngine()
|
||||
engine.Cmds["bd"] = script.Program(exe, nil, 100*time.Millisecond)
|
||||
|
||||
// Run all tests
|
||||
scripttest.Test(t, context.Background(), engine, nil, "testdata/*.txt")
|
||||
}
|
||||
Reference in New Issue
Block a user