31 lines
1.3 KiB
Go
31 lines
1.3 KiB
Go
package httpapi
|
|
|
|
import (
|
|
"knowledge-governance/internal/dobotaiops"
|
|
"knowledge-governance/internal/qaopsorg"
|
|
"testing"
|
|
)
|
|
|
|
func TestQAUsageConsumesTheCustomRegionCatalog(t *testing.T) {
|
|
p, err := qaopsorg.BuildAttribution(qaopsorg.State{State: "ready", DirectoryID: "fixture-directory", Regions: []qaopsorg.RegionDefinition{{ID: "edu", Name: "国内教育"}}, Rules: []qaopsorg.Rule{{DepartmentID: "a", Region: "edu"}}}, qaopsorg.Directory{Departments: []qaopsorg.Department{{ID: "a", Name: "示例部门"}}, People: []qaopsorg.Person{{ID: "fixture-person", DepartmentIDs: []string{"a"}}}})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
usage := summarizeQAUsage(dobotaiops.UsageGroups{Groups: []dobotaiops.UsageGroup{{Identity: dobotaiops.ActorIdentity{StaffID: "fixture-person"}, Total: 3, Succeeded: 2, Failed: 1}}}, p, dobotaiops.RecordQuery{})
|
|
if usage.Questions != 3 || usage.IdentifiedUsers != 1 {
|
|
t.Fatal("the historical whitelist dropped custom-region events")
|
|
}
|
|
found := false
|
|
for _, row := range usage.Rows {
|
|
if row.Key == "国内教育" {
|
|
found = true
|
|
if row.Questions != 3 || row.RosterPeople == nil || *row.RosterPeople != 1 || row.Users == nil || *row.Users != 1 {
|
|
t.Fatal("custom-region counts or roster denominator were lost")
|
|
}
|
|
}
|
|
}
|
|
if !found {
|
|
t.Fatal("custom-region row missing")
|
|
}
|
|
}
|