Discovery, the finding writer and the vault login names read it; no fixed name. Builds: design 47 G §527, §634 (A-149)
33 lines
1.0 KiB
Go
33 lines
1.0 KiB
Go
package link
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
"git.novox.be/novox/mesh-sdk/go/catalogue"
|
|
)
|
|
|
|
// Design 47 G §527, §634: discovery names the module the engine reads of itself, Wait holds until it is known, and an
|
|
// empty name changes nothing.
|
|
func TestTheOwnNameIsWaitedForAndDiscoveryNamesIt(t *testing.T) {
|
|
o := NewOwnName()
|
|
o.Set("")
|
|
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond)
|
|
defer cancel()
|
|
if _, err := o.Wait(ctx); err == nil || o.Get() != "" {
|
|
t.Fatalf("an unnamed engine's wait ended with %v, name %q", err, o.Get())
|
|
}
|
|
o.Set("the-engine")
|
|
if got, err := o.Wait(context.Background()); err != nil || got != "the-engine" {
|
|
t.Fatalf("waited %q, %v", got, err)
|
|
}
|
|
if got := EngineEndpointMetadata(catalogue.Verb{Name: "composition"}, "n1", o.Get())["module"]; got != "the-engine" {
|
|
t.Fatalf("discovery names the module %q", got)
|
|
}
|
|
var none *OwnName
|
|
if _, err := none.Wait(context.Background()); err == nil || none.Get() != "" {
|
|
t.Fatalf("a session naming none waited: %v", err)
|
|
}
|
|
}
|