-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservice_execute_dispatch_test.go
More file actions
88 lines (81 loc) · 2.27 KB
/
service_execute_dispatch_test.go
File metadata and controls
88 lines (81 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package fizeau
import (
"go/ast"
"go/parser"
"go/token"
"os"
"strings"
"testing"
)
func TestExecuteDispatcherSeamsAreExplicit(t *testing.T) {
fset := token.NewFileSet()
file, err := parser.ParseFile(fset, "service_execute_dispatch.go", nil, 0)
if err != nil {
t.Fatalf("parse service_execute_dispatch.go: %v", err)
}
for _, name := range []string{
"executeRouteResolver",
"executeSessionLogOpener",
"executeEventFanout",
"executeRunnerInvoker",
} {
spec := findTypeSpec(file, name)
if spec == nil {
t.Fatalf("missing %s seam type", name)
}
if _, ok := spec.Type.(*ast.InterfaceType); !ok {
t.Fatalf("%s is %T, want interface type", name, spec.Type)
}
}
}
func TestExecuteDispatcherMovesConcreteRunnerSelectionOutOfExecuteLoop(t *testing.T) {
fset := token.NewFileSet()
file, err := parser.ParseFile(fset, "service_execute.go", nil, 0)
if err != nil {
t.Fatalf("parse service_execute.go: %v", err)
}
for _, imp := range file.Imports {
path := imp.Path.Value
switch path {
case `"github.com/easel/fizeau/internal/harnesses/claude"`,
`"github.com/easel/fizeau/internal/harnesses/codex"`,
`"github.com/easel/fizeau/internal/harnesses/gemini"`,
`"github.com/easel/fizeau/internal/harnesses/opencode"`,
`"github.com/easel/fizeau/internal/harnesses/pi"`:
t.Fatalf("service_execute.go imports concrete runner package %s; selection belongs behind executeRunnerInvoker", path)
}
}
}
func TestVirtualAndScriptMechanicsMovedOutOfRootExecute(t *testing.T) {
data, err := os.ReadFile("service_execute.go")
if err != nil {
t.Fatalf("read service_execute.go: %v", err)
}
src := string(data)
for _, implementationDetail := range []string{
"virtual.response",
"virtual.dict_dir",
"script.stdout",
"script.exit_code",
"script.delay_ms",
} {
if strings.Contains(src, implementationDetail) {
t.Fatalf("service_execute.go still contains runner implementation detail %q", implementationDetail)
}
}
}
func findTypeSpec(file *ast.File, name string) *ast.TypeSpec {
for _, decl := range file.Decls {
gen, ok := decl.(*ast.GenDecl)
if !ok || gen.Tok != token.TYPE {
continue
}
for _, spec := range gen.Specs {
typeSpec, ok := spec.(*ast.TypeSpec)
if ok && typeSpec.Name.Name == name {
return typeSpec
}
}
}
return nil
}