func TestName(t *testing.T) { Convey("Should kill them one.", t, func() { hits := NewTargets() hits.Add(NewWorker()) hits.Add(NewWorker()) hits.Add(NewWorker()) hits.Add(NewWorker()) So(len(hits), ShouldEqual, 4) err := hits.Close() So(err, ShouldBeNil) }) Convey("New kill channels should have a length of 0.", t, func() { k := NewKillChannel() So(len(k), ShouldEqual, 0) }) Convey("Should kill them one.", t, func() { hits := NewTargets() t := &Worker{} hits.Add(t) So(len(hits), ShouldEqual, 1) err := hits.Close() So(err, ShouldBeNil) }) Convey("New Targets collection should have len of zero", t, func() { t := NewTargets() w := NewWorker() t.Add(w) v, ok := t[w.Name()] So(len(t), ShouldEqual, 1) So(v, ShouldNotBeNil) So(ok, ShouldBeTrue) }) Convey("New Targets collection should have len of zero", t, func() { t := NewTargets() So(len(t), ShouldEqual, 0) }) Convey("New Target via literals", t, func() { t := NewTargets() t.AddTarget(&Unnamed{}) So(len(t), ShouldEqual, 1) t.Close() }) Convey("New Target or panic should be fine if no error", t, func() { t := NewTargets() t.AddOrPanic(NewService()) So(len(t), ShouldEqual, 1) t.Close() }) Convey("Should panic when adding a service that failed to instantiate without error", t, func() { defer func() { panicky := recover() err, ok := panicky.(error) So(ok, ShouldBeTrue) So(err, ShouldNotBeNil) }() NewTargets().AddOrPanic(NewServiceWithError()) }) }