Files
gooseek/backend/internal/learning/profile_builder_test.go
home ab48a0632b
Some checks failed
Build and Deploy GooSeek / build-backend (push) Failing after 1m4s
Build and Deploy GooSeek / build-webui (push) Failing after 1m2s
Build and Deploy GooSeek / deploy (push) Has been skipped
feat: CI/CD pipeline + Learning/Medicine/Travel services
- Add Gitea Actions workflow for automated build & deploy
- Add K8s manifests: webui, travel-svc, medicine-svc, sandbox-svc
- Update kustomization for localhost:5000 registry
- Add ingress for gooseek.ru and api.gooseek.ru
- Learning cabinet with onboarding, courses, sandbox integration
- Medicine service with symptom analysis and doctor matching
- Travel service with itinerary planning
- Server setup scripts (NVIDIA/CUDA, K3s, Gitea runner)

Made-with: Cursor
2026-03-02 20:25:44 +03:00

66 lines
1.9 KiB
Go

package learning
import (
"context"
"encoding/json"
"testing"
"github.com/gooseek/backend/internal/llm"
)
func TestInferLevel(t *testing.T) {
tests := []struct {
years float64
want string
}{
{0, "beginner"},
{1.5, "junior"},
{3.2, "middle"},
{6.5, "senior"},
{10, "lead"},
}
for _, tc := range tests {
got := inferLevel(tc.years)
if got != tc.want {
t.Fatalf("inferLevel(%v) = %q, want %q", tc.years, got, tc.want)
}
}
}
func TestExtractJSONBlockFromMarkdown(t *testing.T) {
input := "text before\n```json\n{\"name\":\"Alex\",\"level\":\"junior\"}\n```\ntext after"
got := extractJSONBlock(input)
if got != "{\"name\":\"Alex\",\"level\":\"junior\"}" {
t.Fatalf("unexpected json block: %q", got)
}
}
func TestBuildProfileFromOnboarding(t *testing.T) {
llmClient := &mockLLMClient{
generateFunc: func(ctx context.Context, req llm.StreamRequest) (string, error) {
return `{"name":"Иван","experience_years":1.5,"current_role":"qa","skills":["testing"],"programming_languages":["Go"],"frameworks":[],"education":"BS","industries":["it"],"strengths":["аналитика"],"growth_areas":["backend"],"career_goals":"backend","recommended_tracks":["backend go"],"level":"junior","summary":"Начинающий специалист"}`, nil
},
}
profileJSON, err := BuildProfileFromOnboarding(context.Background(), llmClient, map[string]string{
"experience_level": "junior",
"target_track": "backend go",
"weekly_hours": "10",
})
if err != nil {
t.Fatalf("BuildProfileFromOnboarding error: %v", err)
}
var profile map[string]interface{}
if err := json.Unmarshal(profileJSON, &profile); err != nil {
t.Fatalf("profile json unmarshal: %v", err)
}
if profile["name"] != "Иван" {
t.Fatalf("unexpected name: %v", profile["name"])
}
if profile["level"] != "junior" {
t.Fatalf("unexpected level: %v", profile["level"])
}
}