feat(01-03): add make:plugin and plugin:add scaffolding
- Scaffold a compiling vendor.plugin module with go.mod, plugin.go and config/ - Register the module once in summer.yaml, go.work and the app go.mod - Keep summer build on the same generate-and-compile path and print elapsed time
This commit is contained in:
@@ -1,15 +1,41 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"go/parser"
|
||||
"go/token"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.golem15.com/golem15/summercms/bonfire"
|
||||
)
|
||||
|
||||
func TestToolCommandNames(t *testing.T) {
|
||||
var names []string
|
||||
for _, c := range toolCommands() {
|
||||
names = append(names, c.Name)
|
||||
}
|
||||
for _, want := range []string{"build", "make:plugin", "plugin:add"} {
|
||||
if !slices.Contains(names, want) {
|
||||
t.Fatalf("missing %s in %v", want, names)
|
||||
}
|
||||
}
|
||||
|
||||
var buf bytes.Buffer
|
||||
root := bonfire.NewRoot("summer", toolCommands(), &buf)
|
||||
root.SetArgs([]string{"make:plugin", "--help"})
|
||||
if err := root.Execute(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !strings.Contains(buf.String(), "vendor.plugin") {
|
||||
t.Fatalf("make:plugin help missing argument text:\n%s", buf.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestToolDoesNotImportExamplePlugins(t *testing.T) {
|
||||
roots := []string{".", filepath.Join("..", "..", "internal", "build")}
|
||||
fset := token.NewFileSet()
|
||||
|
||||
Reference in New Issue
Block a user