Skip to content

Commit

Permalink
inline the test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
devinyf committed Feb 20, 2024
1 parent 65fc5f7 commit d28c808
Showing 1 changed file with 38 additions and 22 deletions.
60 changes: 38 additions & 22 deletions callbacks/agent_final_stream_test.go
Original file line number Diff line number Diff line change
@@ -1,37 +1,53 @@
package callbacks

import (
"fmt"
"testing"

"github.com/stretchr/testify/require"
)

type filterFinalStringTestCase struct {
inputStr string
}

func TestFilterFinalString(t *testing.T) {
t.Parallel()

keywork := "Final Answer:"

// correct final string
correctStr := "This is a correct final string."

extraStrAbore := fmt.Sprintf(" some other text.\nFinal Answer: %s", correctStr)
extraStrBefore := fmt.Sprintf(" another text. Final Answer: %s", correctStr)
extraColonWithSpacesBefore := fmt.Sprintf(` : %s`, correctStr)

testCases := []filterFinalStringTestCase{
{correctStr},
{extraStrAbore},
{extraStrBefore},
{extraColonWithSpacesBefore},
cases := []struct {
keyword string
inputStr string
expected string
}{
{
keyword: "Final Answer:",
inputStr: "This is a correct final string.",
expected: "This is a correct final string.",
},
{
keyword: "Final Answer:",
inputStr: " some other text above.\nFinal Answer: This is a correct final string.",
expected: "This is a correct final string.",
},
{
keyword: "Final Answer:",
inputStr: " another text before. Final Answer: This is a correct final string.",
expected: "This is a correct final string.",
},
{
keyword: "Final Answer:",
inputStr: ` : This is a correct final string.`,
expected: "This is a correct final string.",
},
{
keyword: "Customed KeyWord_2:",
inputStr: " some other text above.\nSome Customed KeyWord_2: This is a correct final string.",
expected: "This is a correct final string.",
},
{
keyword: "Customed KeyWord_$#@-123:",
inputStr: " another text before keyword. Some Customed KeyWord_$#@-123: This is a correct final string.",
expected: "This is a correct final string.",
},
}

for _, tc := range testCases {
filteredStr := filterFinalString(tc.inputStr, keywork)
require.Equal(t, filteredStr, correctStr)
for _, tc := range cases {
filteredStr := filterFinalString(tc.inputStr, tc.keyword)
require.Equal(t, tc.expected, filteredStr)
}
}

0 comments on commit d28c808

Please sign in to comment.