41 lines
909 B
Go
41 lines
909 B
Go
package scopes_test
|
|
|
|
import (
|
|
tbase "testing"
|
|
|
|
"git.sr.ht/~cco/go-scopes/app"
|
|
"git.sr.ht/~cco/go-scopes/lib/message"
|
|
"git.sr.ht/~cco/go-scopes/testing"
|
|
"git.sr.ht/~cco/go-scopes/tests/etc"
|
|
)
|
|
|
|
func TestConfig(tb *tbase.T) {
|
|
t := testing.SetUpApp(tb, etc.Config())
|
|
t.Run("app", AppTest)
|
|
t.Run("config", ConfigTest)
|
|
t.Run("send", SendTest)
|
|
t.TearDownApp()
|
|
}
|
|
|
|
func AppTest(t *testing.T) {
|
|
ctx := t.Ctx
|
|
t.AssertEqual(len(ctx.Services()), 3)
|
|
}
|
|
|
|
func ConfigTest(t *testing.T) {
|
|
cfg := etc.Config()
|
|
t.AssertEqual(cfg.Name(), "testing")
|
|
appCfg := cfg.(*app.Cfg)
|
|
t.AssertEqual(appCfg.Home, "tests")
|
|
confCtx := t.Ctx.Services()["config"]
|
|
t.AssertEqual(confCtx.Config().Name(), "config")
|
|
}
|
|
|
|
func SendTest(t *testing.T) {
|
|
ctx := t.Ctx
|
|
rcvr := message.SimpleAddress("testing")
|
|
msg := message.StrMessage("demo")
|
|
rcvr.Send(ctx, msg)
|
|
rcvr = message.SimpleAddress("test-receiver")
|
|
rcvr.Send(ctx, msg)
|
|
}
|