Skip to content

Instantly share code, notes, and snippets.

@meson10
Created November 17, 2015 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meson10/57cc126226dad8c2636f to your computer and use it in GitHub Desktop.
Save meson10/57cc126226dad8c2636f to your computer and use it in GitHub Desktop.
func TestComposeNested(t *testing.T) {
c1 := NewPipe()
c11 := NewComposition(composeOne)
c11.SetMessage(StrMap{"merge-one": 1})
c1.Add(c11)
c2 := NewPipe()
c2.Add(NewFuncComposition(StrMap{"fake-two": 1}))
c21 := NewComposition(composeTwo)
c21.SetMessage(StrMap{"merge-two": 1})
c2.Add(c21)
c1.Add(c2)
msg, _ := c1.Execute(makeMessage(StrMap{"input": 1}), engine)
expected := StrMap{}
msg.Unmarshal(&expected)
for _, key := range []string{"input", "merge-one", "ack-one", "fake-two", "merge-two", "ack-two"} {
if _, ok := expected[key]; !ok {
t.Error("Must have", key, "in final output")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment