Skip to content

Commit aedcb4e

Browse files
Fix lua file evaluation in plural cd services lua
Pretty sure it's not handling relative directories correctly here, this should fix
1 parent 729e692 commit aedcb4e

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

cmd/command/cd/cd_services_lua.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
iofs "io/fs"
66
"os"
7+
"path"
78
"path/filepath"
89
"sort"
910
"strings"
@@ -141,7 +142,7 @@ func luaFolder(folder string) (string, error) {
141142

142143
luaFileContents := make([]string, 0)
143144
for _, file := range luaFiles {
144-
luaContents, err := os.ReadFile(file)
145+
luaContents, err := os.ReadFile(path.Join(folder, file))
145146
if err != nil {
146147
return "", fmt.Errorf("failed to read lua file %s: %w", file, err)
147148
}

cmd/command/cd/cd_services_lua_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,17 @@ values["greeting"] = greet("world")
111111
assert.Equal(t, "hello world", values["greeting"])
112112
}
113113

114+
func TestLuaFolder_WithExistingLuaFixtureFolder(t *testing.T) {
115+
luaDir := filepath.Join("..", "..", "..", "test", "lua")
116+
117+
_, err := os.Stat(luaDir)
118+
require.NoError(t, err, "expected fixture lua directory to exist")
119+
120+
content, err := luaFolder(luaDir)
121+
require.NoError(t, err)
122+
assert.NotEmpty(t, content)
123+
}
124+
114125
// Binding tests – each test mirrors what the real luaBindings helpers produce,
115126
// then asserts that Lua can read those values as expected.
116127

0 commit comments

Comments
 (0)