23 lines
839 B
Go
23 lines
839 B
Go
package privacy
|
|||
|
|
|
||
|
|
import "testing"
|
||
|
|
|
||
|
|
func TestFilterInventoryUsesRequestedCategories(t *testing.T) {
|
||
|
|
counts := map[string]int64{"profile": 1, "conversations": 3, "memories": 2}
|
||
|
|
filtered := filterInventory(counts, map[string]any{"categories": []any{"profile", "memories", "unknown", 12}})
|
||
|
|
if len(filtered) != 2 || filtered["profile"] != 1 || filtered["memories"] != 2 {
|
||
|
|
t.Fatalf("filtered inventory = %#v", filtered)
|
||
|
|
}
|
||
|
|
if _, exists := filtered["conversations"]; exists {
|
||
|
|
t.Fatal("unrequested category must not be returned")
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func TestFilterInventoryDefaultsToAllCategories(t *testing.T) {
|
||
|
|
counts := map[string]int64{"profile": 1, "conversations": 3}
|
||
|
|
filtered := filterInventory(counts, map[string]any{})
|
||
|
|
if len(filtered) != len(counts) || filtered["conversations"] != 3 {
|
||
|
|
t.Fatalf("default inventory = %#v", filtered)
|
||
|
|
}
|
||
|
|
}
|