34 lines
778 B
Go
34 lines
778 B
Go
//go:build integration
|
|
|
|
package main
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
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)
|
|
}
|
|
}
|
|
}
|
|
|
|
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)
|
|
}
|
|
}
|