1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2025-02-13 12:06:31 -05:00
OpenDiablo2/d2core/d2systems/file_source_resolver_test.go
gravestench caafe7592c more work on ecs impl
* added command line arg for launching ecs impl
* removed render system tests, was causing gl context issues in tests
* fixed all lint errors in d2systems
2020-12-07 12:44:11 -08:00

56 lines
1.2 KiB
Go

package d2systems
import (
"testing"
"github.com/gravestench/akara"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2components"
)
func Test_FileSourceResolution(t *testing.T) {
const testDataPath = "./testdata/"
cfg := akara.NewWorldConfig()
srcResolver := NewFileSourceResolver()
fileTypeResolver := NewFileTypeResolver()
cfg.With(fileTypeResolver).
With(srcResolver)
world := akara.NewWorld(cfg)
filepathMap, err := world.GetMap(d2components.FilePath)
if err != nil {
t.Error("file path component map not found")
}
filePaths := filepathMap.(*d2components.FilePathMap)
sourceEntity := world.NewEntity()
sourceFp := filePaths.AddFilePath(sourceEntity)
sourceFp.Path = testDataPath
_ = world.Update(0)
ft, found := fileTypeResolver.GetFileType(sourceEntity)
if !found {
t.Error("file source type not created for entity")
}
if ft.Type != d2enum.FileTypeDirectory {
t.Error("expected file system source type for entity")
}
fs, found := srcResolver.fileSources.GetFileSource(sourceEntity)
if !found {
t.Error("file source not created for entity")
}
if fs.AbstractSource == nil {
t.Error("nil file AbstractSource interface inside of file source component")
}
}