feat(cli): command-line client for administration
- Add parsimony list, member, held, archive and queue subcommands over the REST API - Read the token only from PARSIMONY_API_TOKEN; take the URL from --url or PARSIMONY_URL - Print tables by default and JSON with --json - Add member import from a file or stdin, reporting failing lines and exiting non-zero - Require --yes for destructive commands - Add parsimony serve; keep the old -config invocation working - Run the CLI inside the container in the end-to-end test - Test every command against the real API handler; mutation checks over the CLI
This commit is contained in:
parent
77fcdb3bbe
commit
2d8b0ccce6
1 changed files with 1412 additions and 2 deletions
|
|
@ -519,6 +519,31 @@ func TestWholePath(t *testing.T) {
|
|||
}
|
||||
})
|
||||
|
||||
t.Run("the CLI works inside the read-only container", func(t *testing.T) {
|
||||
out, err := docker("exec", parsimonyC, "/parsimony", "list", "ls")
|
||||
if err != nil || !strings.Contains(out, list) {
|
||||
t.Fatalf("list ls: %v\n%s", err, out)
|
||||
}
|
||||
// Bulk import through stdin, as when migrating from Mailman.
|
||||
imp := exec.Command("docker", "exec", "-i", parsimonyC, "/parsimony", "member", "import", list, "-")
|
||||
imp.Stdin = strings.NewReader("# exported subscribers\nalice@members.test\nerin@members.test,Erin\n")
|
||||
b, err := imp.CombinedOutput()
|
||||
if err != nil || !strings.Contains(string(b), "Imported 2") {
|
||||
t.Fatalf("member import: %v\n%s", err, b)
|
||||
}
|
||||
out, _ = docker("exec", parsimonyC, "/parsimony", "member", "ls", list, "--emails")
|
||||
if !strings.Contains(out, "erin@members.test") || !strings.Contains(out, "alice@members.test") {
|
||||
t.Fatalf("members: %s", out)
|
||||
}
|
||||
// Failures give a non-zero exit status.
|
||||
if out, err := docker("exec", parsimonyC, "/parsimony", "list", "show", "ghost@"+domain); err == nil || !strings.Contains(out, "no such list") {
|
||||
t.Fatalf("an unknown list must fail: %v %s", err, out)
|
||||
}
|
||||
if out, err := docker("exec", parsimonyC, "/parsimony", "queue", "ls"); err != nil || !strings.Contains(out, "Pending:") {
|
||||
t.Fatalf("queue ls: %v %s", err, out)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("the queue ends empty", func(t *testing.T) {
|
||||
waitQueueEmpty(t)
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue