1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2025-02-18 14:36:44 -05:00
OpenDiablo2/d2core/d2systems/game_config_test.go

52 lines
1.3 KiB
Go
Raw Normal View History

2020-10-12 17:35:11 -04:00
package d2systems
import (
"testing"
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2components"
"github.com/gravestench/akara"
)
func Test_GameConfigSystem_Bootstrap(t *testing.T) {
cfg := akara.NewWorldConfig()
typeSys := NewFileTypeResolver()
handleSys := NewFileHandleResolver()
srcSys := NewFileSourceResolver()
cfgSys := NewGameConfigSystem()
2020-10-12 17:35:11 -04:00
cfg.With(typeSys).
With(srcSys).
With(handleSys).
With(cfgSys)
2020-10-12 17:35:11 -04:00
world := akara.NewWorld(cfg)
// for the purpose of this test, we want to add the testdata directory, so that
// when the game looks for the config file it gets pulled from there
filePathsAbstract, err := world.GetMap(d2components.FilePath)
if err != nil {
t.Error("file path component map not found")
return
}
filePaths := filePathsAbstract.(*d2components.FilePathMap)
cfgDir := filePaths.AddFilePath(world.NewEntity())
cfgDir.Path = "./testdata/"
cfgFile := filePaths.AddFilePath(world.NewEntity())
cfgFile.Path = "config.json"
2020-10-12 17:35:11 -04:00
// at this point the world has initialized the systems. when the world
// 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)
if len(cfgSys.gameConfigs.GetEntities()) < 1 {
2020-10-12 17:35:11 -04:00
t.Error("no game configs were loaded")
}
}