Split the unit level from the integration level in cmd, builder, link, catalogue, inventory; cheap fixtures for the archive-entry bound, the registry waits and the catalogue copy (issue 895)
This commit is contained in:
@@ -3,7 +3,6 @@ package main
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -55,19 +54,6 @@ func TestAMissingFileIsRefused(t *testing.T) {
|
||||
}
|
||||
|
||||
// The command refuses what it cannot act on, rather than acting on part of it.
|
||||
func TestTheArgumentsAreRequired(t *testing.T) {
|
||||
for _, args := range [][]string{
|
||||
{},
|
||||
{"accept"},
|
||||
{"accept", "anchor"},
|
||||
{"accept", "anchor", "umami"},
|
||||
{"give", "anchor", "umami", "database"},
|
||||
} {
|
||||
if err := secretCommand(t.Context(), args); err == nil {
|
||||
t.Errorf("%v was accepted", args)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The invocation that actually gets used, which the first version of these tests never tried.
|
||||
//
|
||||
@@ -92,16 +78,6 @@ func TestTheArgumentsAndTheFlagAreBothSeen(t *testing.T) {
|
||||
// Testing `split` alone left the command able to ignore it entirely — removing the call changed
|
||||
// no test. This reaches secretCommand: with a `--from` naming a file that is not there, the
|
||||
// complaint must be about the file. A complaint about usage would mean the flag was never seen.
|
||||
func TestTheCommandItselfSeesTheFlag(t *testing.T) {
|
||||
err := secretCommand(t.Context(),
|
||||
[]string{"accept", "anchor", "umami", "database", "--from", "/nonexistent/nowhere"})
|
||||
if err == nil {
|
||||
t.Fatal("a missing file was accepted")
|
||||
}
|
||||
if strings.Contains(err.Error(), "secret accept <node>") {
|
||||
t.Fatalf("the command did not see its flag and complained about usage instead: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func assert(t *testing.T, ok bool, format string, args ...any) {
|
||||
t.Helper()
|
||||
|
||||
Reference in New Issue
Block a user