From 4a0a403e7e73151939e7a9988ba2e0221900e7a9 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 31 Jul 2024 11:26:03 +0800 Subject: [PATCH] feat: Add testPrepare function for initializing test environment --- runtime/runtime_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/runtime/runtime_test.go b/runtime/runtime_test.go index 3adf0664..17465030 100644 --- a/runtime/runtime_test.go +++ b/runtime/runtime_test.go @@ -1,15 +1,36 @@ package runtime import ( + "os" "testing" + "github.com/yaoapp/gou/application" "github.com/yaoapp/yao/config" ) func TestStart(t *testing.T) { + testPrepare(t) defer Stop() err := Start(config.Conf) if err != nil { t.Fatal(err) } } + +func testPrepare(t *testing.T, rootEnv ...string) { + + appRootEnv := "YAO_TEST_APPLICATION" + if len(rootEnv) > 0 { + appRootEnv = rootEnv[0] + } + + root := os.Getenv(appRootEnv) + var app application.Application + var err error + + app, err = application.OpenFromDisk(root) // Load app from Disk + if err != nil { + t.Fatal(err) + } + application.Load(app) +}