test(cabana): unit tests for mail permissions, save validation, drift, reset, layout delete and test send
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -14,7 +14,9 @@ import (
|
||||
|
||||
"git.golem15.com/golem15/summercms/modules/backpack"
|
||||
"git.golem15.com/golem15/summercms/modules/compass"
|
||||
"git.golem15.com/golem15/summercms/modules/cooler"
|
||||
"git.golem15.com/golem15/summercms/modules/party"
|
||||
"github.com/alicebob/miniredis/v2"
|
||||
"github.com/testcontainers/testcontainers-go"
|
||||
"github.com/testcontainers/testcontainers-go/wait"
|
||||
)
|
||||
@@ -254,3 +256,58 @@ func TestBuildRouterNeverDials(t *testing.T) {
|
||||
t.Fatalf("Redis was dialled %d times without installCooler", n)
|
||||
}
|
||||
}
|
||||
|
||||
func TestInstallCoolerPublishesAttempter(t *testing.T) {
|
||||
t.Run("memory_publishes_neither", func(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
for name, body := range map[string]string{
|
||||
"app.yaml": "name: cooler-mem\n",
|
||||
"http.yaml": "body_limits:\n default_bytes: 1048576\n upload_bytes: 1048576\nrate_limit:\n store: memory\n",
|
||||
} {
|
||||
if err := os.WriteFile(filepath.Join(dir, name), []byte(body), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
cfg, err := compass.Open(compass.Options{Dir: dir, Environ: []string{"SUMMER_ENV=development"}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
app := backpack.New(cfg)
|
||||
hd, err := installCooler(context.Background(), app)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _ = hd.Close() })
|
||||
if _, ok := app.Lookup[Store](); ok {
|
||||
t.Fatal("memory store must not publish surf.Store")
|
||||
}
|
||||
if _, ok := app.Lookup[cooler.Attempter](); ok {
|
||||
t.Fatal("memory store must not publish cooler.Attempter")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("redis_publishes_same_store", func(t *testing.T) {
|
||||
mr, err := miniredis.Run()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(mr.Close)
|
||||
app := redisStoreApp(t, "redis://"+mr.Addr()+"/0")
|
||||
hd, err := installCooler(context.Background(), app)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _ = hd.Close() })
|
||||
store, ok := app.Lookup[Store]()
|
||||
if !ok {
|
||||
t.Fatal("redis path must publish surf.Store")
|
||||
}
|
||||
att, ok := app.Lookup[cooler.Attempter]()
|
||||
if !ok {
|
||||
t.Fatal("redis path must publish cooler.Attempter")
|
||||
}
|
||||
if store != att {
|
||||
t.Fatalf("Attempter %T is not the published Store %T", att, store)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user