github.com/alkemics/goflow@v0.2.1/wrappers/after/wrappers_test.go (about) 1 package after 2 3 import ( 4 "testing" 5 6 "github.com/alkemics/goflow/gfutil" 7 "github.com/stretchr/testify/suite" 8 ) 9 10 type afterSuite struct { 11 suite.Suite 12 } 13 14 func (s afterSuite) TestWrap() { 15 node := gfutil.DummyNodeRenderer{ 16 PreviousVal: []string{ 17 "a", 18 }, 19 } 20 unmarshal := func(v interface{}) error { 21 a := v.(*after) 22 *a = after{ 23 After: []string{"b", "c"}, 24 } 25 26 return nil 27 } 28 29 wrapped, err := Wrapper(unmarshal, node) 30 s.Assert().NoError(err) 31 s.Assert().Equal([]string{"a", "b", "c"}, wrapped.Previous()) 32 } 33 34 func (s afterSuite) TestNoAfter() { 35 node := gfutil.DummyNodeRenderer{ 36 PreviousVal: []string{ 37 "a", 38 }, 39 } 40 unmarshal := func(v interface{}) error { 41 return nil 42 } 43 44 wrapped, err := Wrapper(unmarshal, node) 45 s.Assert().NoError(err) 46 s.Assert().Equal([]string{"a"}, wrapped.Previous()) 47 } 48 49 func TestAfterSuite(t *testing.T) { 50 suite.Run(t, new(afterSuite)) 51 }