-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
98 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package agent | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hupe1980/golc/schema" | ||
"github.com/hupe1980/golc/tool" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestToolNames(t *testing.T) { | ||
tools := []schema.Tool{ | ||
tool.NewSleep(), | ||
tool.NewHuman(), | ||
} | ||
|
||
expected := "Sleep, Human" | ||
result := toolNames(tools) | ||
|
||
assert.Equal(t, expected, result) | ||
} | ||
|
||
func TestToolDescriptions(t *testing.T) { | ||
tools := []schema.Tool{ | ||
tool.NewSleep(), | ||
tool.NewHuman(), | ||
} | ||
|
||
expected := `- Sleep: Make agent sleep for a specified number of seconds. | ||
- Human: You can ask a human for guidance when you think you got stuck or you are not sure what to do next. The input should be a question for the human.` | ||
|
||
result := toolDescriptions(tools) | ||
|
||
assert.Equal(t, expected, result) | ||
} | ||
|
||
func TestInputsToString(t *testing.T) { | ||
inputValues := map[string]any{ | ||
"param1": "value1", | ||
"param2": "value2", | ||
} | ||
|
||
expected := map[string]string{ | ||
"param1": "value1", | ||
"param2": "value2", | ||
} | ||
|
||
result, err := inputsToString(inputValues) | ||
assert.NoError(t, err) | ||
assert.Equal(t, expected, result) | ||
|
||
// Test case with non-string input value | ||
inputValues["param3"] = nil | ||
_, err = inputsToString(inputValues) | ||
assert.Error(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters