40 lines
		
	
	
	
		
			873 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
	
		
			873 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package scopes
 | 
						|
 | 
						|
import (
 | 
						|
	"os"
 | 
						|
	tbase "testing"
 | 
						|
 | 
						|
	lib "git.sr.ht/~cco/go-scopes"
 | 
						|
	"git.sr.ht/~cco/go-scopes/common/testing"
 | 
						|
	"git.sr.ht/~cco/go-scopes/core/message"
 | 
						|
	"git.sr.ht/~cco/go-scopes/tests/etc"
 | 
						|
)
 | 
						|
 | 
						|
func TestMatrixApp(tb *tbase.T) {
 | 
						|
	logfile := "log/matrix.log"
 | 
						|
	os.Remove(logfile) // make sure we start with a fresh log file
 | 
						|
	t := testing.SetUpApp(tb, etc.ConfigMx())
 | 
						|
	t.Run("app-matrix", MxTest)
 | 
						|
	t.TearDownApp("matrix")
 | 
						|
	t.AssertEqual(t.LogCheck(logfile, true), 6)
 | 
						|
}
 | 
						|
 | 
						|
func MxTest(t *testing.T) {
 | 
						|
	ctx := t.Ctx
 | 
						|
	t.AssertEqual(len(ctx.Services()), 3)
 | 
						|
	rcvr := message.SimpleAddress("cell-0")
 | 
						|
	msg := message.SimpleMessage("create")
 | 
						|
	lib.Send(ctx, rcvr, msg)
 | 
						|
}
 | 
						|
 | 
						|
// action handlers
 | 
						|
 | 
						|
func MxReceiver(act lib.Action) bool {
 | 
						|
	t := testing.GetT(act.Context())
 | 
						|
	t.AssertEqual(act.Message().Action(), "demo")
 | 
						|
	return true
 | 
						|
}
 | 
						|
 | 
						|
func init() {
 | 
						|
	etc.AH_MxReceiver = MxReceiver
 | 
						|
}
 |