From dedf3a0368f3db327ec662fc0f15412ff1facac9 Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Sat, 15 Jun 2019 17:52:55 -0600 Subject: [PATCH] mcmp: rename GetSeries* functions to just Series* --- mcmp/series.go | 8 ++++---- mcmp/series_test.go | 16 ++++++++-------- mrun/hook.go | 2 +- mtest/mtest.go | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/mcmp/series.go b/mcmp/series.go index e9789ed..644fa6d 100644 --- a/mcmp/series.go +++ b/mcmp/series.go @@ -56,19 +56,19 @@ func AddSeriesValue(c *Component, key, value interface{}) { c.SetValue(numValueElsKey, lastNumValueEls+1) } -// GetSeriesElements returns the sequence of values that have been added to the +// SeriesElements returns the sequence of values that have been added to the // Component under the given key via AddSeriesValue, interlaced with children // which have been spawned from the Component, in the same respective order the // events originally happened. -func GetSeriesElements(c *Component, key interface{}) []SeriesElement { +func SeriesElements(c *Component, key interface{}) []SeriesElement { els, _ := getSeriesElements(c, key) return els } -// GetSeriesValues returns the sequence of values that have been added to the +// SeriesValues returns the sequence of values that have been added to the // Component under the given key via AddSeriesValue, in the same order the // values were added. -func GetSeriesValues(c *Component, key interface{}) []interface{} { +func SeriesValues(c *Component, key interface{}) []interface{} { elsKey, numValueElsKey := seriesKeys(key) els, _ := c.Value(elsKey).([]SeriesElement) numValueEls, _ := c.Value(numValueElsKey).(int) diff --git a/mcmp/series_test.go b/mcmp/series_test.go index bf62e7b..32fb6d7 100644 --- a/mcmp/series_test.go +++ b/mcmp/series_test.go @@ -12,15 +12,15 @@ func TestSeries(t *T) { // test empty state c := new(Component) massert.Require(t, - massert.Length(GetSeriesElements(c, key), 0), - massert.Length(GetSeriesValues(c, key), 0), + massert.Length(SeriesElements(c, key), 0), + massert.Length(SeriesValues(c, key), 0), ) // test after a single value has been added AddSeriesValue(c, key, 1) massert.Require(t, - massert.Equal([]SeriesElement{{Value: 1}}, GetSeriesElements(c, key)), - massert.Equal([]interface{}{1}, GetSeriesValues(c, key)), + massert.Equal([]SeriesElement{{Value: 1}}, SeriesElements(c, key)), + massert.Equal([]interface{}{1}, SeriesValues(c, key)), ) // test after a child has been added @@ -28,9 +28,9 @@ func TestSeries(t *T) { massert.Require(t, massert.Equal( []SeriesElement{{Value: 1}, {Child: childA}}, - GetSeriesElements(c, key), + SeriesElements(c, key), ), - massert.Equal([]interface{}{1}, GetSeriesValues(c, key)), + massert.Equal([]interface{}{1}, SeriesValues(c, key)), ) // test after another value has been added @@ -38,8 +38,8 @@ func TestSeries(t *T) { massert.Require(t, massert.Equal( []SeriesElement{{Value: 1}, {Child: childA}, {Value: 2}}, - GetSeriesElements(c, key), + SeriesElements(c, key), ), - massert.Equal([]interface{}{1, 2}, GetSeriesValues(c, key)), + massert.Equal([]interface{}{1, 2}, SeriesValues(c, key)), ) } diff --git a/mrun/hook.go b/mrun/hook.go index 3bab3f8..555d600 100644 --- a/mrun/hook.go +++ b/mrun/hook.go @@ -29,7 +29,7 @@ func triggerHooks( key interface{}, next func([]mcmp.SeriesElement) (mcmp.SeriesElement, []mcmp.SeriesElement), ) error { - els := mcmp.GetSeriesElements(cmp, hookKey{key}) + els := mcmp.SeriesElements(cmp, hookKey{key}) var el mcmp.SeriesElement for { if len(els) == 0 { diff --git a/mtest/mtest.go b/mtest/mtest.go index f24308d..d17ba06 100644 --- a/mtest/mtest.go +++ b/mtest/mtest.go @@ -21,7 +21,7 @@ func Component() *mcmp.Component { mlog.SetLogger(cmp, logger) mrun.InitHook(cmp, func(context.Context) error { - envVals := mcmp.GetSeriesValues(cmp, envCmpKey(0)) + envVals := mcmp.SeriesValues(cmp, envCmpKey(0)) env := make([]string, 0, len(envVals)) for _, val := range envVals { tup := val.([2]string)