oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package runner
2
3import (
4 "amadan.net/oficina/equipo/internal/runnerproto"
5 "context"
6 "encoding/json"
7 "testing"
8)
9
10func TestDirectUploadUsesEventIdentity(t *testing.T) {
11 s, r, _, _ := cleanupFixture(t)
12 e := Event{Version: 2, ID: "stale-A", AssignmentID: "attempt-A", Scope: r.Claim.Scope, Handle: r.Claim.Handle}
13 e.Handle.Attempt++
14 e.Handle.Fence++
15 s.api = apiFuncR3(func(_ context.Context, _ string, q runnerproto.RunnerRequest, _ any) error {
16 var saved Event
17 mustJournal(t, json.Unmarshal(q.Event, &saved))
18 if q.AssignmentID != saved.AssignmentID || q.Scope != saved.Scope || q.Handle != saved.Handle {
19 return runnerproto.ErrInvalid
20 }
21 return nil
22 })
23 mustJournal(t, s.uploadDirectEvent(context.Background(), r, e))
24}
25func TestDirectCloseDrainsFinalEvents(t *testing.T) {
26 done := make(chan error, 1)
27 pending, uploaded := 0, 0
28 err := finishDirectStream(context.Background(), func() error { pending++; done <- nil; return nil }, done, func(context.Context) error { uploaded += pending; pending = 0; return nil })
29 mustJournal(t, err)
30 if uploaded != 1 || pending != 0 {
31 t.Fatal("close event not drained")
32 }
33}
34