From 4ddce8915ff28e11332b8d1f52c392ac5ed1d215 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Mon, 9 Jul 2018 20:20:45 +0000 Subject: [PATCH] Test Sets.Add() --- report/sets_test.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/report/sets_test.go b/report/sets_test.go index e8b8866988..c29e42e659 100644 --- a/report/sets_test.go +++ b/report/sets_test.go @@ -8,6 +8,37 @@ import ( "github.com/weaveworks/scope/test/reflect" ) +func TestSetsAdd(t *testing.T) { + for _, testcase := range []struct { + a report.Sets + want map[string][]string + }{ + { + report.MakeSets().Add("a", report.MakeStringSet("b")), + map[string][]string{"a": {"b"}}, + }, + { + report.MakeSets().Add("a", report.MakeStringSet("b")).Add("a", report.MakeStringSet("c")), + map[string][]string{"a": {"b", "c"}}, + }, + { + report.MakeSets().Add("a", report.MakeStringSet("b", "c")).Add("a", report.MakeStringSet("c")), + map[string][]string{"a": {"b", "c"}}, + }, + { + report.MakeSets().Add("a", report.MakeStringSet("c")).Add("a", report.MakeStringSet("b", "c")), + map[string][]string{"a": {"b", "c"}}, + }, + { + report.MakeSets().Add("a", report.MakeStringSet("1")).Add("b", report.MakeStringSet("2")). + Add("c", report.MakeStringSet("3")).Add("b", report.MakeStringSet("3")), + map[string][]string{"a": {"1"}, "b": {"2", "3"}, "c": {"3"}}, + }, + } { + check(t, "Add", testcase.a, testcase.want) + } +} + func TestSetsMerge(t *testing.T) { for _, testcase := range []struct { a, b report.Sets