Files
hyperguild/internal/skills/sessionlog/handlers_test.go
T
mathiasandClaude Sonnet 5 b600cc986c
CI / Lint / Test / Vet (push) Failing after 5s
CI / Mirror to GitHub (push) Has been skipped
chore(module): rename module github.com/mathiasbq/supervisor -> git.d-ma.be/mathias/hyperguild (#42)
Aligns module path with canonical Gitea source (infra ADR-0004) and
repo name. Binary only, no downstream consumers.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Roq1ajWKR5f1hG5Df9wC6A
2026-07-26 23:37:11 +02:00

45 lines
1.2 KiB
Go

// internal/skills/sessionlog/handlers_test.go
package sessionlog_test
import (
"context"
"encoding/json"
"os"
"path/filepath"
"testing"
"git.d-ma.be/mathias/hyperguild/internal/skills/sessionlog"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestHandle_SessionLog_AppendsEntry(t *testing.T) {
dir := t.TempDir()
s := sessionlog.New(sessionlog.Config{SessionsDir: dir})
args, _ := json.Marshal(map[string]any{
"session_id": "sess-abc",
"skill": "tdd_green",
"final_status": "pass",
"model_used": "ollama/qwen3",
"duration_ms": 3000,
})
out, err := s.Handle(context.Background(), "session_log", args)
require.NoError(t, err)
var result map[string]string
require.NoError(t, json.Unmarshal(out, &result))
assert.Equal(t, "ok", result["status"])
// Verify file written
data, err := os.ReadFile(filepath.Join(dir, "sess-abc.jsonl"))
require.NoError(t, err)
assert.Contains(t, string(data), "tdd_green")
}
func TestHandle_SessionLog_RequiresSessionID(t *testing.T) {
s := sessionlog.New(sessionlog.Config{SessionsDir: t.TempDir()})
args, _ := json.Marshal(map[string]any{"skill": "tdd_red"})
_, err := s.Handle(context.Background(), "session_log", args)
assert.Error(t, err)
}