Harden self-update recovery (T-617)
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"softbox.local/core/updater"
|
||||
)
|
||||
|
||||
func TestAcknowledgeInternalUpdateHealthRejectsMalformedArguments(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
args []string
|
||||
handled bool
|
||||
wantErr bool
|
||||
}{
|
||||
{name: "ordinary launch", args: nil},
|
||||
{name: "other internal-looking flag", args: []string{"--softbox-other"}},
|
||||
{name: "missing request ID", args: []string{updater.InternalHealthFlag}, handled: true, wantErr: true},
|
||||
{name: "extra argument", args: []string{updater.InternalHealthFlag, "update-1234", "extra"}, handled: true, wantErr: true},
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
handled, err := acknowledgeInternalUpdateHealth(test.args)
|
||||
if handled != test.handled || (err != nil) != test.wantErr {
|
||||
t.Fatalf("acknowledgeInternalUpdateHealth(%q) = handled=%t, err=%v; want handled=%t, error=%t", test.args, handled, err, test.handled, test.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user