From 8d657b6fdf5570e3c0324ec5086ee8aad88171ac Mon Sep 17 00:00:00 2001 From: Ophestra Date: Fri, 17 Apr 2026 21:30:00 +0900 Subject: cmd/mbf: cancel remote cure This exposes the new fine-grained cancel API in cmd/mbf. Signed-off-by: Ophestra --- cmd/mbf/daemon_test.go | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'cmd/mbf/daemon_test.go') 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"), + ) } } -- cgit v1.3.1