aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd/mbf/daemon_test.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-04-17 21:30:00 +0900
committerOphestra <cat@gensokyo.uk>2026-04-17 22:00:04 +0900
commit8d657b6fdf5570e3c0324ec5086ee8aad88171ac (patch)
treea286f28f3dc98dab72bacbf65749117a747887ab /cmd/mbf/daemon_test.go
parentae9b9adfd28e7ea8609f769473754277334da255 (diff)
cmd/mbf: cancel remote cure
This exposes the new fine-grained cancel API in cmd/mbf. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'cmd/mbf/daemon_test.go')
-rw-r--r--cmd/mbf/daemon_test.go24
1 files changed, 20 insertions, 4 deletions
diff --git a/cmd/mbf/daemon_test.go b/cmd/mbf/daemon_test.go
index 6fd95a96..3306eea3 100644
--- a/cmd/mbf/daemon_test.go
+++ b/cmd/mbf/daemon_test.go
@@ -9,6 +9,8 @@ import (
"net"
"os"
"path/filepath"
+ "slices"
+ "strings"
"testing"
"time"
@@ -104,11 +106,17 @@ func TestDaemon(t *testing.T) {
}
}()
+ if err = cancelRemote(ctx, &addr, pkg.NewFile("nonexistent", nil)); err != nil {
+ t.Fatalf("cancelRemote: error = %v", err)
+ }
+
+ // keep this last for synchronisation
var p *check.Absolute
p, err = cureRemote(ctx, &addr, pkg.NewFile("check", []byte{0}), 0)
if err != nil {
t.Fatalf("cureRemote: error = %v", err)
}
+
cancel()
<-done
@@ -117,9 +125,17 @@ func TestDaemon(t *testing.T) {
t.Errorf("cureRemote: %s, want %s", got, want)
}
- const wantLog = `daemon: fulfilled artifact fiZf-ZY_Yq6qxJNrHbMiIPYCsGkUiKCRsZrcSELXTqZWtCnESlHmzV5ThhWWGGYG
-`
- if gotLog := buf.String(); gotLog != wantLog {
- t.Errorf("serve: logged\n%s\nwant\n%s", gotLog, wantLog)
+ wantLog := []string{
+ "",
+ "daemon: attempting to cancel invalid artifact kQm9fmnCmXST1-MMmxzcau2oKZCXXrlZydo4PkeV5hO_2PKfeC8t98hrbV_ZZx_j",
+ "daemon: fulfilled artifact fiZf-ZY_Yq6qxJNrHbMiIPYCsGkUiKCRsZrcSELXTqZWtCnESlHmzV5ThhWWGGYG",
+ }
+ gotLog := strings.Split(buf.String(), "\n")
+ slices.Sort(gotLog)
+ if !slices.Equal(gotLog, wantLog) {
+ t.Errorf(
+ "serve: logged\n%s\nwant\n%s",
+ strings.Join(gotLog, "\n"), strings.Join(wantLog, "\n"),
+ )
}
}