Skip to content

Commit

Permalink
review comments: add new api GetSubstraitTestsFS
Browse files Browse the repository at this point in the history
  • Loading branch information
scgkiran committed Nov 13, 2024
1 parent 48a2a7c commit 985a2ed
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
18 changes: 13 additions & 5 deletions core.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@ package substrait

import "embed"

// Add all directories which should be exposed in below
//
//go:embed extensions/*
//go:embed tests/cases/*/*
var substraitFS embed.FS
var substraitExtensionsFS embed.FS

func GetSubstraitFS() embed.FS {
return substraitFS
return substraitExtensionsFS
}

func GetSubstraitExtensionsFS() embed.FS {
return substraitExtensionsFS
}

//go:embed tests/cases/*/*.test
var substraitTestsFS embed.FS

func GetSubstraitTestsFS() embed.FS {
return substraitTestsFS
}
22 changes: 15 additions & 7 deletions core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,27 @@ import (
"github.com/stretchr/testify/require"
)

func TestGetSubstraitFS(t *testing.T) {
got := GetSubstraitFS()
func TestGetSubstraitExtensionsFS(t *testing.T) {
fsArr := []embed.FS{GetSubstraitExtensionsFS(), GetSubstraitFS()}
for _, got := range fsArr {
filePaths, err := ListFiles(got, ".")
require.NoError(t, err)
assert.Greater(t, len(filePaths), 15)
assert.Contains(t, filePaths, "extensions/functions_arithmetic.yaml")
assert.Contains(t, filePaths, "extensions/functions_arithmetic_decimal.yaml")
assert.Contains(t, filePaths, "extensions/functions_datetime.yaml")
}
}

func TestGetSubstraitTestsFS(t *testing.T) {
got := GetSubstraitTestsFS()
filePaths, err := ListFiles(got, ".")
require.NoError(t, err)
assert.Greater(t, len(filePaths), 19)
assert.Greater(t, len(filePaths), 3)
assert.Contains(t, filePaths, "tests/cases/arithmetic/add.test")
assert.Contains(t, filePaths, "tests/cases/arithmetic/max.test")
assert.Contains(t, filePaths, "tests/cases/arithmetic_decimal/power.test")
assert.Contains(t, filePaths, "tests/cases/datetime/lt_datetime.test")

assert.Contains(t, filePaths, "extensions/functions_arithmetic.yaml")
assert.Contains(t, filePaths, "extensions/functions_arithmetic_decimal.yaml")
assert.Contains(t, filePaths, "extensions/functions_datetime.yaml")
}

func ListFiles(embedFs embed.FS, root string) ([]string, error) {
Expand Down

0 comments on commit 985a2ed

Please sign in to comment.