You've already forked factorio-server-manager
mirror of
https://github.com/OpenFactorioServerManager/factorio-server-manager.git
synced 2025-07-15 01:14:28 +02:00
fixed compatibility between 0.18/1.0
This commit is contained in:
@ -523,3 +523,64 @@ func TestModUploadHandler(t *testing.T) {
|
|||||||
assert.Equal(t, http.StatusInternalServerError, recorder.Code, "wrong response code.")
|
assert.Equal(t, http.StatusInternalServerError, recorder.Code, "wrong response code.")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_018_10_Compatibility(t *testing.T) {
|
||||||
|
CheckShort(t)
|
||||||
|
|
||||||
|
var err error
|
||||||
|
|
||||||
|
// set test environment to verson 1.0.0
|
||||||
|
factorio.SetFactorioServer(factorio.Server{
|
||||||
|
Version: factorio.Version{1, 0, 0, 0},
|
||||||
|
BaseModVersion: "1.0.0",
|
||||||
|
})
|
||||||
|
|
||||||
|
// when done reset the environment to what it should be
|
||||||
|
defer factorio.SetFactorioServer(factorio.Server{
|
||||||
|
Version: factorio.Version{1, 1, 6, 0},
|
||||||
|
BaseModVersion: "1.1.6",
|
||||||
|
})
|
||||||
|
|
||||||
|
// manually setup the environment, it has to be specific
|
||||||
|
|
||||||
|
config := bootstrap.GetConfig()
|
||||||
|
|
||||||
|
// check if dev directory exists and create it
|
||||||
|
if _, err = os.Stat(config.FactorioModsDir); os.IsNotExist(err) {
|
||||||
|
err = os.Mkdir(config.FactorioModsDir, 0775)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf(`Error creating "dev" directory: %s`, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
mod, err := factorio.NewMods(config.FactorioModsDir)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("couldn't create Mods object: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = mod.DownloadMod("/download/belt-balancer/5e9f9db4bf9d30000c5303f2", "belt-balancer_2.1.3.zip", "belt-balancer")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf(`Error downloading Mod "belt-balancer": %s`, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
defer CleanupMods(t)
|
||||||
|
|
||||||
|
route := "/api/mods/list"
|
||||||
|
|
||||||
|
expected := `[
|
||||||
|
{
|
||||||
|
"name": "belt-balancer",
|
||||||
|
"version": "2.1.3",
|
||||||
|
"title": "Belt Balancer",
|
||||||
|
"author": "knoxfighter",
|
||||||
|
"file_name": "belt-balancer_2.1.3.zip",
|
||||||
|
"factorio_version": "0.18.0.0",
|
||||||
|
"dependencies": null,
|
||||||
|
"compatibility": true,
|
||||||
|
"enabled": true
|
||||||
|
}
|
||||||
|
]`
|
||||||
|
|
||||||
|
CallRoute(t, "GET", route, route, nil, ListInstalledModsHandler, http.StatusOK, expected)
|
||||||
|
}
|
||||||
|
@ -114,7 +114,7 @@ func (modInfoList *ModInfoList) listInstalledMods() error {
|
|||||||
modInfo.Compatibility = server.Version.Compatible(base, op)
|
modInfo.Compatibility = server.Version.Compatible(base, op)
|
||||||
} else {
|
} else {
|
||||||
log.Println("error finding basemodDependency. Using FactorioVersion...")
|
log.Println("error finding basemodDependency. Using FactorioVersion...")
|
||||||
modInfo.Compatibility = !server.Version.Less(modInfo.FactorioVersion)
|
modInfo.Compatibility = server.Version.GreaterC(modInfo.FactorioVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
modInfoList.Mods = append(modInfoList.Mods, modInfo)
|
modInfoList.Mods = append(modInfoList.Mods, modInfo)
|
||||||
|
@ -70,7 +70,7 @@ func (v Version) Greater(b Version) bool { return !v.Equals(b) && !v.Less(b) }
|
|||||||
// GreaterC called to determine the compatibility with a greater version
|
// GreaterC called to determine the compatibility with a greater version
|
||||||
// Versions, that have different super/major version are not compatible!
|
// Versions, that have different super/major version are not compatible!
|
||||||
func (v *Version) GreaterC(b Version) bool {
|
func (v *Version) GreaterC(b Version) bool {
|
||||||
return v[0] == b[0] && v[1] == b[1] && (v[2] > b[2] || (v[2] == b[2] && v[3] > b[3]))
|
return (v[0] == b[0] && v[1] == b[1] && (v[2] > b[2] || (v[2] == b[2] && v[3] > b[3]))) || (v[0] == 1 && b[0] == 0 && v[1] == 0 && b[1] == 18)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v Version) ge(b Version) bool { return v.Equals(b) || v.Greater(b) }
|
func (v Version) ge(b Version) bool { return v.Equals(b) || v.Greater(b) }
|
||||||
|
Reference in New Issue
Block a user