Files
summercms/backpack/app_test.go
Jakub Zych 36c152f4bb test(01-02): add failing test for typed events and context
- Cover Fire/Collect/UntilHandled, priority, panics and bus isolation
- Require towel actor/org/collection/locale accessors on context
- Assert hello command demonstrates all three dispatch modes
2026-09-16 13:27:53 +02:00

51 lines
1.0 KiB
Go

package backpack
import (
"go/parser"
"go/token"
"os"
"strconv"
"strings"
"testing"
"git.golem15.com/golem15/summercms/compass"
)
func TestEventBusesAreAppScoped(t *testing.T) {
a := New(&compass.Config{})
b := New(&compass.Config{})
if a.Events == nil || b.Events == nil {
t.Fatal("App must own an event bus")
}
if a.Events == b.Events {
t.Fatal("apps must not share a bus")
}
}
func TestDoesNotImportParty(t *testing.T) {
entries, err := os.ReadDir(".")
if err != nil {
t.Fatal(err)
}
fset := token.NewFileSet()
for _, entry := range entries {
name := entry.Name()
if entry.IsDir() || !strings.HasSuffix(name, ".go") || strings.HasSuffix(name, "_test.go") {
continue
}
file, err := parser.ParseFile(fset, name, nil, parser.ImportsOnly)
if err != nil {
t.Fatal(err)
}
for _, spec := range file.Imports {
path, err := strconv.Unquote(spec.Path.Value)
if err != nil {
t.Fatal(err)
}
if path == "git.golem15.com/golem15/summercms/party" {
t.Fatalf("%s imports party", name)
}
}
}
}