test(09-02): add failing tests for admin create and reset commands

- admin:create and admin:reset-password are not registered yet
- Generated app main does not append cabana runtime commands
This commit is contained in:
Jakub Zych
2026-09-24 17:54:42 +02:00
parent 9740c3dcdb
commit d27f442c49
3 changed files with 224 additions and 0 deletions

View File

@@ -109,6 +109,22 @@ func TestGenerateStableQuotedImportsInManifestOrder(t *testing.T) {
}
}
func TestGenerateMainRegistersCabanaRuntimeCommands(t *testing.T) {
mainSrc, err := generateMain(Manifest{Module: "example.com/app", Binary: "hello"})
if err != nil {
t.Fatal(err)
}
if bytes.Count(mainSrc, []byte("cabana.RuntimeCommands")) != 1 {
t.Fatalf("cabana.RuntimeCommands count = %d\n%s", bytes.Count(mainSrc, []byte("cabana.RuntimeCommands")), mainSrc)
}
if !bytes.Contains(mainSrc, []byte("commands = append(commands, cabana.RuntimeCommands(app)...)")) {
t.Fatalf("generated main does not append cabana runtime commands once:\n%s", mainSrc)
}
if bytes.Contains(mainSrc, []byte("examples/hello")) {
t.Fatal("generated main hard-codes examples/hello")
}
}
func TestWriteIfChangedSkipsIdenticalBytes(t *testing.T) {
dir := t.TempDir()
path := filepath.Join(dir, "out.go")