41 lines
1.7 KiB
Go
41 lines
1.7 KiB
Go
package link
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
// **Both implementations, one fixture.** The point of the seam is not that the transport can be
|
|
// swapped — it is that the two can be held to the same envelope while both ship, so the day the
|
|
// bus moves is a configuration change rather than a discovery.
|
|
//
|
|
// Against a real server, because what the fixture pins is what reaches the wire:
|
|
//
|
|
// go test ./internal/link/ -run TestTheNatsBus (each test on a bus of its own: internal/testbus)
|
|
|
|
// The subject a declaration lands on is one node's, and nothing else's — the state shape.
|
|
func TestADeclarationIsAddressedToOneNode(t *testing.T) {
|
|
if got := DeclareSubject("anchor"); got != "mesh.node.anchor.declare" {
|
|
t.Fatalf("a declaration would go to %q", got)
|
|
}
|
|
if DeclareSubject("anchor") == DeclareSubject("laptop") {
|
|
t.Fatal("two nodes share a declaration subject, so each would apply the other's")
|
|
}
|
|
}
|
|
|
|
// A module cannot emit under another's name: the subject is derived from the source, and the
|
|
// server's permissions make that subject the authority.
|
|
func TestAnEventsSubjectIsDerivedFromItsSource(t *testing.T) {
|
|
if got := EventSubject("shop", "order.placed"); got != "mesh.mod.shop.event.order.placed" {
|
|
t.Fatalf("an event would land on %q", got)
|
|
}
|
|
if EventSubject("shop", "x") == EventSubject("billing", "x") {
|
|
t.Fatal("two modules share an event subject, so neither owns its own name")
|
|
}
|
|
}
|
|
|
|
// A tool nobody serves says so at once. The difference between "that module is down" and "that
|
|
// tool is slow" is the first thing a person asking wants, and waiting out the timeout to say it
|
|
// is how a fast answer becomes a slow non-answer.
|
|
|
|
// And a served tool answers, with no reply queue to declare and no correlation to check.
|