test(cabana,flare,dev,summer): json, reported errors and dev serve
- Docker: admin:token:create and list --json, -q keeps the token - flare generate and test-push failures print once and are Reported - summer dev starts serve with the forwarded globals, reports rebuilds, failures and restarts, and stops serve with SIGTERM returning nil - delegates carry two examples and say the global options pass through
This commit is contained in:
@@ -236,3 +236,55 @@ func TestNewAppCmdCancelSendsSIGTERM(t *testing.T) {
|
||||
t.Fatalf("child was not stopped with SIGTERM:\n%s", out.String())
|
||||
}
|
||||
}
|
||||
|
||||
// TestDelegateExamples: every delegate has two examples rendered after
|
||||
// summer in its help, and its long help says that flags and the global
|
||||
// options pass to the app binary; global options before or after the
|
||||
// command word reach the app binary.
|
||||
func TestDelegateExamples(t *testing.T) {
|
||||
got := captureAppRunner(t)
|
||||
for _, c := range delegateCommands() {
|
||||
if len(c.Examples) != 2 {
|
||||
t.Errorf("%s has %d examples, want 2", c.Name, len(c.Examples))
|
||||
}
|
||||
if !strings.Contains(c.Long, "global options (-v, -q, --ansi, --no-ansi, -n, --env)") || !strings.Contains(c.Long, "passed to the app binary unchanged") {
|
||||
t.Errorf("%s: long help does not say that global options pass through:\n%s", c.Name, c.Long)
|
||||
}
|
||||
out, err := runSummer(t, "help", c.Name)
|
||||
if err != nil {
|
||||
t.Fatalf("help %s: %v", c.Name, err)
|
||||
}
|
||||
for _, e := range c.Examples {
|
||||
if !strings.HasPrefix(e.Command, c.Name) || e.Description == "" {
|
||||
t.Errorf("%s: example %+v does not start with the command or lacks a description", c.Name, e)
|
||||
}
|
||||
if !strings.Contains(out, " summer "+e.Command+"\n") || !strings.Contains(out, "# "+e.Description) {
|
||||
t.Errorf("help %s lacks the example %q:\n%s", c.Name, e.Command, out)
|
||||
}
|
||||
}
|
||||
}
|
||||
if *got != nil {
|
||||
t.Fatalf("help ran the app binary with %q", *got)
|
||||
}
|
||||
if problems := bonfire.CheckDocs(delegateCommands()); len(problems) != 0 {
|
||||
t.Errorf("delegates lack documentation: %v", problems)
|
||||
}
|
||||
|
||||
for _, tc := range []struct {
|
||||
args []string
|
||||
want []string
|
||||
}{
|
||||
{[]string{"-v", "migrate", "--pretend"}, []string{"migrate", "-v", "--pretend"}},
|
||||
{[]string{"migrate", "-qn"}, []string{"migrate", "-qn"}},
|
||||
{[]string{"--env", "staging", "queue:work"}, []string{"queue:work", "--env", "staging"}},
|
||||
{[]string{"--no-ansi", "serve", "--addr", ":8123"}, []string{"serve", "--no-ansi", "--addr", ":8123"}},
|
||||
} {
|
||||
got := captureAppRunner(t)
|
||||
if out, err := runSummer(t, tc.args...); err != nil {
|
||||
t.Fatalf("%q: %v\n%s", tc.args, err, out)
|
||||
}
|
||||
if !slices.Equal(*got, tc.want) {
|
||||
t.Errorf("%q: argv = %q, want %q", tc.args, *got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user