feat: add workbench AI integration

This commit is contained in:
richjohnrambo
2026-09-28 11:28:24 +08:00
parent 5bf68727fa
commit 8773991015
19 changed files with 6971 additions and 10 deletions
+49
View File
@@ -0,0 +1,49 @@
package tableparse
import (
"os"
"path/filepath"
"testing"
"github.com/xuri/excelize/v2"
)
func TestParseCSVBuildsProfile(t *testing.T) {
dir := t.TempDir()
path := filepath.Join(dir, "sales.csv")
if err := os.WriteFile(path, []byte("date,sales,orders\n8/1,100,2\n8/2,200,4\n"), 0o600); err != nil {
t.Fatal(err)
}
profile, err := Parse(path, "csv")
if err != nil {
t.Fatal(err)
}
if !profile.Parsed || profile.RowCount != 2 {
t.Fatalf("profile parsed=%v rowCount=%d, want parsed=true rowCount=2", profile.Parsed, profile.RowCount)
}
if got := profile.Stats["sales"].Sum; got != 300 {
t.Fatalf("sales sum = %v, want 300", got)
}
}
func TestParseXLSXBuildsProfile(t *testing.T) {
dir := t.TempDir()
path := filepath.Join(dir, "sales.xlsx")
f := excelize.NewFile()
if err := f.SetSheetRow("Sheet1", "A1", &[]any{"date", "sales"}); err != nil {
t.Fatal(err)
}
if err := f.SetSheetRow("Sheet1", "A2", &[]any{"8/1", 120}); err != nil {
t.Fatal(err)
}
if err := f.SaveAs(path); err != nil {
t.Fatal(err)
}
profile, err := Parse(path, "xlsx")
if err != nil {
t.Fatal(err)
}
if !profile.Parsed || profile.Columns[1].Type != "number" {
t.Fatalf("profile parsed=%v sales type=%q, want parsed=true number", profile.Parsed, profile.Columns[1].Type)
}
}