Skip to content

Commit

Permalink
feat: Add testPrepare function for initializing test environment
Browse files Browse the repository at this point in the history
  • Loading branch information
trheyi committed Jul 31, 2024
1 parent a0729bb commit 4a0a403
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions runtime/runtime_test.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit 4a0a403

Please sign in to comment.