From fa8d827eee297d6c0e93eae239cb5a1839948c79 Mon Sep 17 00:00:00 2001 From: Jort Rodenburg Date: Mon, 12 Jul 2021 10:45:01 -0700 Subject: [PATCH] Parse funcRef refName correctly Signed-off-by: Jort Rodenburg --- model/function.go | 2 +- parser/parser_test.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/model/function.go b/model/function.go index af3b514..8ea6472 100644 --- a/model/function.go +++ b/model/function.go @@ -58,7 +58,7 @@ func (f *FunctionRef) UnmarshalJSON(data []byte) error { return nil } - f.RefName = requiresNotNilOrEmpty("refName") + f.RefName = requiresNotNilOrEmpty(funcRef["refName"]) if _, found := funcRef["arguments"]; found { f.Arguments = funcRef["arguments"].(map[string]interface{}) } diff --git a/parser/parser_test.go b/parser/parser_test.go index bd74e2a..33a2c34 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -26,12 +26,14 @@ func TestFromFile(t *testing.T) { "./testdata/greetings.sw.json": func(t *testing.T, w *model.Workflow) { assert.Equal(t, "greeting", w.ID) assert.IsType(t, &model.OperationState{}, w.States[0]) + assert.Equal(t, "greetingFunction", w.States[0].(*model.OperationState).Actions[0].FunctionRef.RefName) }, "./testdata/greetings.sw.yaml": func(t *testing.T, w *model.Workflow) { assert.IsType(t, &model.OperationState{}, w.States[0]) assert.Equal(t, "greeting", w.ID) assert.NotEmpty(t, w.States[0].(*model.OperationState).Actions) assert.NotNil(t, w.States[0].(*model.OperationState).Actions[0].FunctionRef) + assert.Equal(t, "greetingFunction", w.States[0].(*model.OperationState).Actions[0].FunctionRef.RefName) }, "./testdata/eventbasedgreeting.sw.json": func(t *testing.T, w *model.Workflow) { assert.Equal(t, "GreetingEvent", w.Events[0].Name)