-
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
5 changed files
with
45 additions
and
2 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
File renamed without changes.
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,41 @@ | ||
package toolkit | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hupe1980/golc/schema" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// TestNewBrowser tests the creation of a new Browser object | ||
func TestNewBrowser(t *testing.T) { | ||
browser, err := NewBrowser(nil) | ||
require.NoError(t, err) | ||
require.NotNil(t, browser) | ||
|
||
// Ensure that the Browser has the expected tools | ||
expectedToolNames := []string{ | ||
"CurrentPage", | ||
"NavigateBrowser", | ||
"ExtractText", | ||
} | ||
tools := browser.Tools() | ||
require.Len(t, tools, len(expectedToolNames)) | ||
|
||
for _, name := range expectedToolNames { | ||
assertToolExists(t, tools, name) | ||
} | ||
} | ||
|
||
// assertToolExists checks if a tool with the specified name exists in the list of tools. | ||
func assertToolExists(t *testing.T, tools []schema.Tool, name string) { | ||
t.Helper() | ||
|
||
for _, tool := range tools { | ||
if tool.Name() == name { | ||
return // Found the tool | ||
} | ||
} | ||
|
||
require.Fail(t, "tool not found: "+name) | ||
} |
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,2 @@ | ||
// package toolkit provides a collection of tools. | ||
package toolkit |