2020-10-12 17:35:11 -04:00
|
|
|
package d2systems
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/gravestench/akara"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Test_GameConfigSystem_Bootstrap(t *testing.T) {
|
2020-11-22 16:18:50 -05:00
|
|
|
const testDataPath = "testdata"
|
2020-11-22 04:37:55 -05:00
|
|
|
|
2020-10-12 17:35:11 -04:00
|
|
|
cfg := akara.NewWorldConfig()
|
|
|
|
|
2020-11-28 00:45:58 -05:00
|
|
|
typeSys := &FileTypeResolver{}
|
|
|
|
handleSys := &FileHandleResolver{}
|
|
|
|
srcSys := &FileSourceResolver{}
|
|
|
|
cfgSys := &GameConfigSystem{}
|
2020-10-12 17:35:11 -04:00
|
|
|
|
2020-11-18 21:33:22 -05:00
|
|
|
cfg.With(typeSys).
|
|
|
|
With(srcSys).
|
|
|
|
With(handleSys).
|
|
|
|
With(cfgSys)
|
2020-10-12 17:35:11 -04:00
|
|
|
|
|
|
|
world := akara.NewWorld(cfg)
|
|
|
|
|
2020-11-28 00:45:58 -05:00
|
|
|
cfgSys.AddFilePath(world.NewEntity()).Path = testDataPath
|
|
|
|
cfgSys.AddFilePath(world.NewEntity()).Path = "config.json"
|
2020-10-12 17:35:11 -04:00
|
|
|
|
2020-12-02 01:24:31 -05:00
|
|
|
// at this point the world has initialized the baseSystems. when the world
|
2020-11-18 21:33:22 -05:00
|
|
|
// updates it should process the config dir to a source and then
|
|
|
|
// use the source to resolve a file handle, and finally the config file
|
|
|
|
// will get loaded by the config system.
|
2020-10-12 17:35:11 -04:00
|
|
|
_ = world.Update(0)
|
|
|
|
|
2020-11-18 21:33:22 -05:00
|
|
|
if len(cfgSys.gameConfigs.GetEntities()) < 1 {
|
2020-10-12 17:35:11 -04:00
|
|
|
t.Error("no game configs were loaded")
|
|
|
|
}
|
|
|
|
}
|