ficsit-cli-flake/cli/installations_test.go
mircearoata ea983cf851
feat: vanilla toggle per install (#13)
* feat: vanilla toggle per install

* fix: update set-vanilla cmd description

* fix: use viper for the set-vanilla off flag

* fix: writing lockfile when the directory didn't exist

* fix: check for nil selected install in header vanilla message

---------

Co-authored-by: Vilsol <me@vil.so>
2023-12-06 06:02:06 +02:00

45 lines
1.1 KiB
Go

package cli
import (
"os"
"testing"
"github.com/MarvinJWendt/testza"
"github.com/satisfactorymodding/ficsit-cli/cfg"
)
func init() {
cfg.SetDefaults()
}
func TestInstallationsInit(t *testing.T) {
installations, err := InitInstallations()
testza.AssertNoError(t, err)
testza.AssertNotNil(t, installations)
}
func TestAddInstallation(t *testing.T) {
ctx, err := InitCLI(false)
testza.AssertNoError(t, err)
profileName := "InstallationTest"
profile, err := ctx.Profiles.AddProfile(profileName)
testza.AssertNoError(t, err)
testza.AssertNoError(t, profile.AddMod("AreaActions", ">=1.6.5"))
testza.AssertNoError(t, profile.AddMod("ArmorModules__Modpack_All", ">=1.4.1"))
serverLocation := os.Getenv("SF_DEDICATED_SERVER")
if serverLocation != "" {
installation, err := ctx.Installations.AddInstallation(ctx, serverLocation, profileName)
testza.AssertNoError(t, err)
testza.AssertNotNil(t, installation)
err = installation.Install(ctx, nil)
testza.AssertNoError(t, err)
installation.Vanilla = true
err = installation.Install(ctx, nil)
testza.AssertNoError(t, err)
}
}