diff --git a/pkg/africastalking/input.go b/pkg/africastalking/input.go index 25c9ce5..db5050c 100644 --- a/pkg/africastalking/input.go +++ b/pkg/africastalking/input.go @@ -7,6 +7,10 @@ import ( ) func ConcatText(session *core.Session) string { + if session == nil { + return "" + } + inputs := make([]string, 0) for _, step := range session.Steps { inputs = append(inputs, step.Text) diff --git a/pkg/africastalking/input_test.go b/pkg/africastalking/input_test.go index db9de31..e4b3b20 100644 --- a/pkg/africastalking/input_test.go +++ b/pkg/africastalking/input_test.go @@ -8,6 +8,19 @@ import ( "github.com/stretchr/testify/assert" ) +func TestConcatTextWithNilSession(t *testing.T) { + got := africastalking.ConcatText(nil) + assert.Equal(t, "", got) +} + +func TestConcatTextWithNilSteps(t *testing.T) { + got := africastalking.ConcatText(&core.Session{ + Steps: nil, + }) + + assert.Equal(t, "", got) +} + func TestConcatText(t *testing.T) { got := africastalking.ConcatText(&core.Session{ Steps: []*core.Step{