Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions pkg/aiusechat/tools_readdir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"testing"

"github.com/wavetermdev/waveterm/pkg/aiusechat/uctypes"
"github.com/wavetermdev/waveterm/pkg/util/fileutil"
)

func TestReadDirCallback(t *testing.T) {
Expand Down Expand Up @@ -64,16 +65,16 @@ func TestReadDirCallback(t *testing.T) {
t.Errorf("Expected 3 entries, got %d", entryCount)
}

entries, ok := resultMap["entries"].([]map[string]any)
entries, ok := resultMap["entries"].([]fileutil.DirEntryOut)
if !ok {
t.Fatalf("entries is not a slice of maps")
t.Fatalf("entries is not a slice of DirEntryOut")
}

// Check that we have the expected entries
foundFiles := 0
foundDirs := 0
for _, entry := range entries {
if entry["is_dir"].(bool) {
if entry.Dir {
foundDirs++
} else {
foundFiles++
Expand Down Expand Up @@ -208,12 +209,15 @@ func TestReadDirSortBeforeTruncate(t *testing.T) {
}

resultMap := result.(map[string]any)
entries := resultMap["entries"].([]map[string]any)
entries, ok := resultMap["entries"].([]fileutil.DirEntryOut)
if !ok {
t.Fatalf("entries is not a slice of DirEntryOut")
}

// Count directories in the result
dirCount := 0
for _, entry := range entries {
if entry["is_dir"].(bool) {
if entry.Dir {
dirCount++
}
}
Expand All @@ -225,7 +229,7 @@ func TestReadDirSortBeforeTruncate(t *testing.T) {

// First 3 entries should be directories
for i := 0; i < 3; i++ {
if !entries[i]["is_dir"].(bool) {
if !entries[i].Dir {
t.Errorf("Expected entry %d to be a directory, but it was a file", i)
}
}
Expand Down
Loading