feat(platform): filter quality issues by type
This commit is contained in:
@@ -647,6 +647,40 @@ func TestBuildQualityIssueWhereUsesMatchingArgs(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildQualityIssueWhereFiltersIssueType(t *testing.T) {
|
||||
fromSQL, args := buildQualityIssueWhere(url.Values{"issueType": {"NO_SOURCE"}})
|
||||
if !strings.Contains(fromSQL, "q.issue_type = ?") {
|
||||
t.Fatalf("quality issue SQL should filter issue type: %s", fromSQL)
|
||||
}
|
||||
if len(args) != 1 || args[0] != "NO_SOURCE" {
|
||||
t.Fatalf("args = %#v", args)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandlerQualityIssuesFiltersIssueType(t *testing.T) {
|
||||
handler := NewHandler(NewService(NewMockStore()))
|
||||
rec := httptest.NewRecorder()
|
||||
req := httptest.NewRequest(http.MethodGet, "/api/quality/issues?issueType=NO_SOURCE&limit=20", nil)
|
||||
handler.ServeHTTP(rec, req)
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("status = %d body=%s", rec.Code, rec.Body.String())
|
||||
}
|
||||
var body struct {
|
||||
Data Page[QualityIssueRow] `json:"data"`
|
||||
}
|
||||
if err := json.NewDecoder(rec.Body).Decode(&body); err != nil {
|
||||
t.Fatalf("response JSON should decode: %v body=%s", err, rec.Body.String())
|
||||
}
|
||||
if body.Data.Total == 0 {
|
||||
t.Fatalf("expected at least one NO_SOURCE issue")
|
||||
}
|
||||
for _, item := range body.Data.Items {
|
||||
if item.IssueType != "NO_SOURCE" {
|
||||
t.Fatalf("expected only NO_SOURCE issues, got %+v", body.Data.Items)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandlerOpsHealthIncludesVehicleServiceRuntime(t *testing.T) {
|
||||
handler := NewHandler(NewServiceWithRuntime(NewMockStore(), RuntimeInfo{RequestTimeoutMs: 1500}))
|
||||
rec := httptest.NewRecorder()
|
||||
|
||||
Reference in New Issue
Block a user