package vision import ( "context" "encoding/json" "testing" "github.com/photoprism/photoprism/internal/ai/vision/ollama" ) func TestOllamaDefaultConfidenceApplied(t *testing.T) { req := &ApiRequest{Format: FormatJSON} payload := ApiResponseOllama{ Result: ApiResult{ Labels: []LabelResult{{Name: "forest path", Confidence: 0, Topicality: 0}}, }, } raw, err := json.Marshal(payload) if err != nil { t.Fatalf("marshal: %v", err) } parser := ollamaParser{} resp, err := parser.Parse(context.Background(), req, raw, 200) if err != nil { t.Fatalf("parse failed: %v", err) } if len(resp.Result.Labels) != 1 { t.Fatalf("expected one label, got %d", len(resp.Result.Labels)) } if resp.Result.Labels[0].Confidence != ollama.DefaultLabelConfidence { t.Fatalf("expected default confidence %.2f, got %.2f", ollama.DefaultLabelConfidence, resp.Result.Labels[0].Confidence) } if resp.Result.Labels[0].Topicality != ollama.DefaultLabelConfidence { t.Fatalf("expected topicality to default to confidence, got %.2f", resp.Result.Labels[0].Topicality) } }