S6 grants-wait-asks-ready: grants' wait for its catalog half asks the catalog client's Ready, so a mesh naming no branch is none-yet
Builds: design 47 G A-369 (G-22-lead-answers-2.md) Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
@@ -74,6 +74,10 @@ func (c *CatalogOf) Resolve(fingerprint string) (meshcatalog.CatalogEntry, meshc
|
|||||||
func (c *CatalogOf) Waiting() []string {
|
func (c *CatalogOf) Waiting() []string {
|
||||||
followed := c.Branches.Followed()
|
followed := c.Branches.Followed()
|
||||||
if len(followed) == 0 {
|
if len(followed) == 0 {
|
||||||
|
// A mesh whose registrations and gate's source are answered and name no branch is none-yet, as for every part (A-369).
|
||||||
|
if c.Branches.Ready() == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return []string{"no branch is followed yet (the registrations and the gate's source are not answered)"}
|
return []string{"no branch is followed yet (the registrations and the gate's source are not answered)"}
|
||||||
}
|
}
|
||||||
var out []string
|
var out []string
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package grants
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/clients/meshcatalogclient"
|
||||||
|
seat "git.novox.be/novox/mesh-delivery/modules/mesh-delivery-contracts/go/seats/meshcatalog"
|
||||||
|
"git.novox.be/novox/mesh-sdk/go/views"
|
||||||
|
)
|
||||||
|
|
||||||
|
type wiring struct{ followers []*views.Follower }
|
||||||
|
|
||||||
|
func (w *wiring) Adopt(f *views.Follower, _, _ string, _ func(context.Context, []byte) error) error {
|
||||||
|
w.followers = append(w.followers, f)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (w *wiring) Drop(string, string) error { return nil }
|
||||||
|
|
||||||
|
// Design 47 G A-369: the grants part's wait for its catalog half asks the catalog client's Ready, so a mesh whose registrations
|
||||||
|
// and gate's source are answered and name no branch is none-yet for grants, and waits while either is not answered.
|
||||||
|
func TestAMeshThatNamesNoBranchIsNoWaitForGrants(t *testing.T) {
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
call := func(key string, _ any) (json.RawMessage, error) {
|
||||||
|
if key == meshcatalogclient.RegistrationsVerb {
|
||||||
|
return json.Marshal(seat.RegistrationsAnswer{Registrations: []seat.Registration{}})
|
||||||
|
}
|
||||||
|
return json.Marshal(map[string][]string{"branches": {}})
|
||||||
|
}
|
||||||
|
for _, answered := range []bool{false, true} {
|
||||||
|
w := &wiring{}
|
||||||
|
b, err := meshcatalogclient.NewBranches(w, call)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if answered {
|
||||||
|
for _, f := range w.followers {
|
||||||
|
if err := f.Start(ctx); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
got := (&CatalogOf{Branches: b, Context: ctx}).Waiting()
|
||||||
|
if (len(got) == 0) != answered {
|
||||||
|
t.Errorf("answered %v: waiting %v", answered, got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user