summaryrefslogtreecommitdiff
path: root/internal/executor/classifier_test.go
blob: 4de44ca22713fe8f30ffb966b1e82c57dd28f4ef (plain)
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
package executor

import (
	"context"
	"os"
	"testing"
)

// TestClassifier_Classify_Mock tests the classifier with a mocked gemini binary.
func TestClassifier_Classify_Mock(t *testing.T) {
	// Create a temporary mock binary.
	mockBinary := filepathJoin(t.TempDir(), "mock-gemini")
	mockContent := `#!/bin/sh
echo '{"agent_type": "gemini", "model": "gemini-2.0-flash", "reason": "test reason"}'
`
	if err := os.WriteFile(mockBinary, []byte(mockContent), 0755); err != nil {
		t.Fatal(err)
	}

	c := &Classifier{GeminiBinaryPath: mockBinary}
	status := SystemStatus{
		ActiveTasks: map[string]int{"claude": 5, "gemini": 1},
		RateLimited: map[string]bool{"claude": false, "gemini": false},
	}

	cls, err := c.Classify(context.Background(), "Test Task", "Test Instructions", status)
	if err != nil {
		t.Fatalf("Classify failed: %v", err)
	}

	if cls.AgentType != "gemini" {
		t.Errorf("expected gemini, got %s", cls.AgentType)
	}
	if cls.Model != "gemini-2.0-flash" {
		t.Errorf("expected gemini-2.0-flash, got %s", cls.Model)
	}
}

func filepathJoin(elems ...string) string {
	var path string
	for i, e := range elems {
		if i == 0 {
			path = e
		} else {
			path = path + string(os.PathSeparator) + e
		}
	}
	return path
}