This commit is contained in:
maskpp
2023-03-28 09:29:47 +08:00
parent c1f02745e2
commit 59df623b6a
4 changed files with 10 additions and 11 deletions

View File

@@ -38,6 +38,9 @@ func NewBridgeApp(base *docker.App, file string) *BridgeApp {
bridgeFile: bridgeFile,
args: []string{"--log.debug", "--config", bridgeFile},
}
if err := bridgeApp.MockConfig(true); err != nil {
panic(err)
}
return bridgeApp
}

View File

@@ -54,10 +54,6 @@ var (
func TestMain(m *testing.M) {
base = docker.NewDockerApp()
bridgeApp = app.NewBridgeApp(base, "../config.json")
err := bridgeApp.MockConfig(false)
if err != nil {
panic(err)
}
// Load config.
cfg = bridgeApp.Config

View File

@@ -47,7 +47,7 @@ func NewCoordinatorApp(base *docker.App, file string) *CoordinatorApp {
WSPort: wsPort,
args: []string{"--log.debug", "--config", coordinatorFile, "--ws", "--ws.port", strconv.Itoa(int(wsPort))},
}
if err := coordinatorApp.mockConfig(true); err != nil {
if err := coordinatorApp.MockConfig(true); err != nil {
panic(err)
}
return coordinatorApp
@@ -72,8 +72,8 @@ func (c *CoordinatorApp) WSEndpoint() string {
return fmt.Sprintf("ws://localhost:%d", c.WSPort)
}
// mockConfig creates a new coordinator config.
func (c *CoordinatorApp) mockConfig(store bool) error {
// MockConfig creates a new coordinator config.
func (c *CoordinatorApp) MockConfig(store bool) error {
base := c.base
cfg, err := coordinatorConfig.NewConfig(c.originFile)
if err != nil {

View File

@@ -55,7 +55,7 @@ func NewRollerApp(base *docker.App, file string, wsUrl string) *RollerApp {
name: "roller-test",
args: []string{"--log.debug", "--config", rollerFile},
}
if err := rollerApp.mockConfig(true, wsUrl); err != nil {
if err := rollerApp.MockConfig(true, wsUrl); err != nil {
panic(err)
}
return rollerApp
@@ -77,8 +77,8 @@ func (r *RollerApp) Free() {
_ = os.Remove(r.bboltDB)
}
// mockConfig creates a new roller config.
func (r *RollerApp) mockConfig(store bool, wsUrl string) error {
// MockConfig creates a new roller config.
func (r *RollerApp) MockConfig(store bool, wsUrl string) error {
cfg, err := rollerConfig.NewConfig(r.originFile)
if err != nil {
return err
@@ -129,7 +129,7 @@ func (r RollerApps) MockConfigs(store bool, wsUrl string) error {
for _, roller := range r {
roller := roller
eg.Go(func() error {
return roller.mockConfig(store, wsUrl)
return roller.MockConfig(store, wsUrl)
})
}
return eg.Wait()