Return empty JSON arrays from the API and normalize nullable values from older servers before rendering candidate match counts. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
28 lines
881 B
Go
28 lines
881 B
Go
package mapper
|
|
|
|
import (
|
|
"testing"
|
|
|
|
servicemodel "github.com/danyel/go-guess/backend/internal/service/model"
|
|
)
|
|
|
|
func TestInterviewOmitsReferenceAnswer(t *testing.T) {
|
|
response := InterviewToWeb(servicemodel.Interview{
|
|
Job: servicemodel.JobPosting{
|
|
Questions: []servicemodel.Question{{
|
|
ID: 1, Type: "code_review", Text: "Review this",
|
|
CodeSnippet: "return nil", ReferenceAnswer: "Should return the error",
|
|
}},
|
|
},
|
|
}, "http://localhost")
|
|
if len(response.Job.Questions) != 1 || response.Job.Questions[0].CodeSnippet != "return nil" {
|
|
t.Fatalf("expected participant-safe code question, got %#v", response)
|
|
}
|
|
}
|
|
|
|
func TestCandidateAlwaysUsesJSONArrays(t *testing.T) {
|
|
response := CandidateToWeb(servicemodel.CandidateMatch{})
|
|
if response.Matched == nil || response.Missing == nil {
|
|
t.Fatalf("candidate trait collections must not be nil: %#v", response)
|
|
}
|
|
}
|