feat: support JS and Go source files in fission package loader

This commit is contained in:
Naeel
2026-04-14 23:37:32 +03:00
parent d40c5c6e07
commit f9dfb882f0
5 changed files with 83 additions and 5 deletions
@@ -49,6 +49,40 @@ func TestLoadPackageLiteralFromSourceDir(t *testing.T) {
}
}
func TestLoadPackageLiteralFromSourceDirJS(t *testing.T) {
tempDir := t.TempDir()
mainPath := filepath.Join(tempDir, "main.js")
content := []byte("module.exports = async function() { return 'ok'; }\n")
if err := os.WriteFile(mainPath, content, 0o600); err != nil {
t.Fatalf("write temp main.js: %v", err)
}
loaded, err := loadPackageLiteral(tempDir, "")
if err != nil {
t.Fatalf("loadPackageLiteral returned error: %v", err)
}
if string(loaded) != string(content) {
t.Fatalf("unexpected loaded content")
}
}
func TestLoadPackageLiteralFromSourceDirGo(t *testing.T) {
tempDir := t.TempDir()
mainPath := filepath.Join(tempDir, "main.go")
content := []byte("package main\nfunc main() {}\n")
if err := os.WriteFile(mainPath, content, 0o600); err != nil {
t.Fatalf("write temp main.go: %v", err)
}
loaded, err := loadPackageLiteral(tempDir, "")
if err != nil {
t.Fatalf("loadPackageLiteral returned error: %v", err)
}
if string(loaded) != string(content) {
t.Fatalf("unexpected loaded content")
}
}
func TestPackageToUnstructured(t *testing.T) {
input := packageResourceModel{
Name: types.StringValue("pkg-a"),