github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/test/integration/migrator_int_test.go (about) 1 package integration 2 3 import ( 4 "fmt" 5 "path/filepath" 6 "testing" 7 8 "github.com/ActiveState/cli/internal/constants" 9 "github.com/ActiveState/cli/internal/fileutils" 10 "github.com/ActiveState/cli/internal/testhelpers/e2e" 11 "github.com/ActiveState/cli/internal/testhelpers/suite" 12 "github.com/ActiveState/cli/internal/testhelpers/tagsuite" 13 "github.com/ActiveState/cli/pkg/projectfile" 14 ) 15 16 type MigratorIntegrationTestSuite struct { 17 tagsuite.Suite 18 } 19 20 func (suite *MigratorIntegrationTestSuite) TestMigrator() { 21 suite.OnlyRunForTags(tagsuite.Migrations, tagsuite.Critical) 22 ts := e2e.New(suite.T(), false) 23 defer ts.Close() 24 25 ts.PrepareProject("ActiveState-CLI/small-python", "5a1e49e5-8ceb-4a09-b605-ed334474855b") 26 27 cp := ts.SpawnWithOpts(e2e.OptArgs("refresh")) 28 cp.ExpectExitCode(0, e2e.RuntimeSourcingTimeoutOpt) 29 30 suite.Require().Contains(string(fileutils.ReadFileUnsafe(filepath.Join(ts.Dirs.Work, constants.ConfigFileName))), 31 fmt.Sprintf("config_version: %d", projectfile.ConfigVersion), ts.DebugMessage("")) 32 } 33 34 func (suite *MigratorIntegrationTestSuite) TestMigrator_Buildscripts() { 35 suite.OnlyRunForTags(tagsuite.Migrations, tagsuite.BuildScripts, tagsuite.Critical) 36 ts := e2e.New(suite.T(), false) 37 defer ts.Close() 38 39 cp := ts.Spawn("config", "set", constants.OptinBuildscriptsConfig, "true") 40 cp.ExpectExitCode(0) 41 42 ts.PrepareProject("ActiveState-CLI/small-python", "5a1e49e5-8ceb-4a09-b605-ed334474855b") 43 44 suite.Require().NoFileExists(filepath.Join(ts.Dirs.Work, constants.BuildScriptFileName)) 45 46 cp = ts.SpawnWithOpts(e2e.OptArgs("refresh"), e2e.OptAppendEnv(constants.DisableRuntime+"=false")) 47 cp.ExpectExitCode(0, e2e.RuntimeSourcingTimeoutOpt) 48 49 suite.Require().FileExists(filepath.Join(ts.Dirs.Work, constants.BuildScriptFileName), ts.DebugMessage("")) 50 } 51 52 func TestMigratorIntegrationTestSuite(t *testing.T) { 53 suite.Run(t, new(MigratorIntegrationTestSuite)) 54 }