42 lines
1.3 KiB
Go
42 lines
1.3 KiB
Go
package process
|
|
|
|
import "testing"
|
|
|
|
// 1191/AC3: given a module tool key <module>.<tool>, when called, then the subject is
|
|
// mesh.mod.<module>.call.<tool>.<token> with the same fallback (mesh.mod.<module>.tool.<tool>).
|
|
func TestCallSubjectsForAModuleTool(t *testing.T) {
|
|
called, fallback, err := callSubjects("mesh-mail.send", "novox~mesh-mail~send")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if called != "mesh.mod.mesh-mail.call.send.novox~mesh-mail~send" {
|
|
t.Errorf("called: %q", called)
|
|
}
|
|
if fallback != "mesh.mod.mesh-mail.tool.send" {
|
|
t.Errorf("fallback: %q", fallback)
|
|
}
|
|
}
|
|
|
|
// 1191/AC1's subject (the seat form): seat:<seat>.<verb> calls mesh.seat.<seat>.call.<verb>.<token>,
|
|
// falling back to mesh.seat.<seat>.tool.<verb>.
|
|
func TestCallSubjectsForASeatVerb(t *testing.T) {
|
|
called, fallback, err := callSubjects("seat:operator-channel.tell", "novox~mesh-mail~send")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if called != "mesh.seat.operator-channel.call.tell.novox~mesh-mail~send" {
|
|
t.Errorf("called: %q", called)
|
|
}
|
|
if fallback != "mesh.seat.operator-channel.tool.tell" {
|
|
t.Errorf("fallback: %q", fallback)
|
|
}
|
|
}
|
|
|
|
func TestCallSubjectsRefusesAKeyNamingNeither(t *testing.T) {
|
|
for _, key := range []string{"", "nodot", "seat:", "seat:noverb", "."} {
|
|
if _, _, err := callSubjects(key, "token"); err == nil {
|
|
t.Errorf("callSubjects(%q) was accepted", key)
|
|
}
|
|
}
|
|
}
|