mirror of
https://github.com/phishingclub/phishingclub.git
synced 2026-12-06 01:53:42 +01:00
30 lines
1.2 KiB
Go
30 lines
1.2 KiB
Go
package service
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/phishingclub/phishingclub/model"
|
|
"github.com/phishingclub/phishingclub/repository"
|
|
)
|
|
|
|
// TestMergeFieldValuesCap checks more than the listed number of values is
|
|
// cut and flagged, with the total of all values and the members of the values
|
|
// that are not listed
|
|
func TestMergeFieldValuesCap(t *testing.T) {
|
|
rows := []repository.FieldValueCount{}
|
|
for i := 0; i < model.MaxRecipientFieldValues+20; i++ {
|
|
rows = append(rows, repository.FieldValueCount{Value: "v" + uuid.NewString(), Count: 1})
|
|
}
|
|
rows = append(rows, repository.FieldValueCount{Value: "", Count: 3})
|
|
got := mergeFieldValues(model.LanguageRouteCity, &repository.FieldValueCounts{
|
|
Rows: rows, Members: model.MaxRecipientFieldValues + 23, Distinct: len(rows),
|
|
})
|
|
if len(got.Values) != model.MaxRecipientFieldValues || !got.Truncated || got.Total != model.MaxRecipientFieldValues+20 {
|
|
t.Fatalf("cap: %d values, truncated %v, total %d", len(got.Values), got.Truncated, got.Total)
|
|
}
|
|
if got.EmptyCount != 3 || got.UnlistedCount != 20 {
|
|
t.Fatalf("empty %d and unlisted %d, want 3 and 20", got.EmptyCount, got.UnlistedCount)
|
|
}
|
|
}
|