Files
VERSE 1e04949242 refactor: better project structure (#35)
This project is starting to grow, and I've seen flaws in the initial
project structure design
I think I'll restructure the entire project directory for better
scalability and also cleaner
2026-07-11 16:15:05 +07:00

39 lines
1.1 KiB
Go

package tests
import (
"os"
"path/filepath"
"testing"
_ "github.com/versenilvis/iris/commands/runner"
"github.com/versenilvis/iris/spec"
)
// Verify that the just command generator parses recipes and returns nil on read errors
func TestJustGenerator(t *testing.T) {
tmp := t.TempDir()
content := []byte("# build project\nbuild:\n\techo build\n")
_ = os.WriteFile(filepath.Join(tmp, "justfile"), content, 0644)
oldWd, _ := os.Getwd()
_ = os.Chdir(tmp)
defer func() { _ = os.Chdir(oldWd) }()
s := spec.Registry["just"]
if s == nil || s.Generator == nil {
t.Fatalf("expected just spec with generator to be registered in Registry")
}
res := s.Generator([]string{"just", ""}, "just ", "")
if len(res) != 1 || res[0].Cmd != "build" || res[0].Desc != "build project" {
t.Fatalf("expected recipe build with comment, got %v", res)
}
// Verify missing file returns nil
_ = os.Remove(filepath.Join(tmp, "justfile"))
resMissing := s.Generator([]string{"just", ""}, "just ", "")
if resMissing != nil {
t.Fatalf("expected nil when justfile cannot be read, got %v", resMissing)
}
}