51 lines
1.1 KiB
Go
51 lines
1.1 KiB
Go
package analyzer
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
)
|
|
|
|
func TestCleanJSONResponse(t *testing.T) {
|
|
cases := []struct {
|
|
input string
|
|
expected string
|
|
}{
|
|
{
|
|
input: "```json\n{\"ai_score\": 90}\n```",
|
|
expected: "{\"ai_score\": 90}",
|
|
},
|
|
{
|
|
input: "```\n{\"ai_score\": 85}\n```",
|
|
expected: "{\"ai_score\": 85}",
|
|
},
|
|
{
|
|
input: "{\"ai_score\": 95}",
|
|
expected: "{\"ai_score\": 95}",
|
|
},
|
|
}
|
|
|
|
for _, c := range cases {
|
|
out := cleanJSONResponse(c.input)
|
|
if out != c.expected {
|
|
t.Errorf("cleanJSONResponse(%q) = %q, expected %q", c.input, out, c.expected)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestMockAnalyzer(t *testing.T) {
|
|
mock := NewMockAnalyzer()
|
|
res, err := mock.AnalyzeJD(context.Background(), "Senior AI Infrastructure Engineer", "Building GKE and K8s runtimes.")
|
|
if err != nil {
|
|
t.Fatalf("unexpected error: %v", err)
|
|
}
|
|
if res.AIScore <= 0 {
|
|
t.Errorf("expected positive AI score, got %f", res.AIScore)
|
|
}
|
|
if !res.IsQualified {
|
|
t.Errorf("expected IsQualified=true, got false")
|
|
}
|
|
if len(res.MatchedHighlights) == 0 {
|
|
t.Errorf("expected matched highlights to not be empty")
|
|
}
|
|
}
|