feat: support JS and Go source files in fission package loader
This commit is contained in:
@@ -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"),
|
||||
|
||||
Reference in New Issue
Block a user