|
| 1 | +package bot |
| 2 | + |
| 3 | +import ( |
| 4 | + "encoding/json" |
| 5 | + "testing" |
| 6 | + |
| 7 | + "github.com/stretchr/testify/assert" |
| 8 | + "github.com/stretchr/testify/require" |
| 9 | +) |
| 10 | + |
| 11 | +func TestBuildMCPConfig(t *testing.T) { |
| 12 | + config := BuildMCPConfig("/usr/local/bin/yatz") |
| 13 | + |
| 14 | + var parsed map[string]interface{} |
| 15 | + err := json.Unmarshal([]byte(config), &parsed) |
| 16 | + require.NoError(t, err) |
| 17 | + |
| 18 | + servers := parsed["mcpServers"].(map[string]interface{}) |
| 19 | + yatzcli := servers["yatzcli"].(map[string]interface{}) |
| 20 | + assert.Equal(t, "/usr/local/bin/yatz", yatzcli["command"]) |
| 21 | + |
| 22 | + args := yatzcli["args"].([]interface{}) |
| 23 | + assert.Equal(t, []interface{}{"mcp"}, args) |
| 24 | +} |
| 25 | + |
| 26 | +func TestBuildPrompt(t *testing.T) { |
| 27 | + prompt := BuildPrompt("localhost:9876", "TestBot", "test strategy") |
| 28 | + |
| 29 | + assert.Contains(t, prompt, "localhost:9876") |
| 30 | + assert.Contains(t, prompt, "TestBot") |
| 31 | + assert.Contains(t, prompt, "test strategy") |
| 32 | + assert.Contains(t, prompt, "join_game") |
| 33 | + assert.Contains(t, prompt, "wait_for_turn") |
| 34 | + assert.Contains(t, prompt, "roll_dice") |
| 35 | + assert.Contains(t, prompt, "score") |
| 36 | + assert.Contains(t, prompt, "send_chat") |
| 37 | + // Critical: instruction not to call wait_for_turn after score |
| 38 | + assert.Contains(t, prompt, "score 後に wait_for_turn を呼ぶな") |
| 39 | +} |
| 40 | + |
| 41 | +func TestBuildSystemPrompt(t *testing.T) { |
| 42 | + prompt := BuildSystemPrompt("my strategy") |
| 43 | + assert.Contains(t, prompt, "ヤッツィー") |
| 44 | + assert.Contains(t, prompt, "my strategy") |
| 45 | +} |
0 commit comments