Debian Codegraph @

cmd/commands_test.go

raw symbols ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 package caddycmd
2
3 import (
4 "maps"
5 "reflect"
6 "slices"
7 "testing"
8 )
9
10 func TestCommandsAreAvailable(t *testing.T) {
11 // trigger init, and build the default factory, so that
12 // all commands from this package are available
13 cmd := defaultFactory.Build()
14 if cmd == nil {
15 t.Fatal("default factory failed to build")
16 }
17
18 // check that the default factory has 17 commands; it doesn't
19 // include the commands registered through calls to init in
20 // other packages
21 cmds := Commands()
22 if len(cmds) != 17 {
23 t.Errorf("expected 17 commands, got %d", len(cmds))
24 }
25
26 commandNames := slices.Collect(maps.Keys(cmds))
27 slices.Sort(commandNames)
28
29 expectedCommandNames := []string{
30 "adapt", "add-package", "build-info", "completion",
31 "environ", "fmt", "list-modules", "manpage",
32 "reload", "remove-package", "run", "start",
33 "stop", "storage", "upgrade", "validate", "version",
34 }
35
36 if !reflect.DeepEqual(expectedCommandNames, commandNames) {
37 t.Errorf("expected %v, got %v", expectedCommandNames, commandNames)
38 }
39 }