github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/test/integration/bundle_int_test.go (about) 1 package integration 2 3 import ( 4 "testing" 5 6 "github.com/ActiveState/cli/internal/testhelpers/e2e" 7 "github.com/ActiveState/cli/internal/testhelpers/suite" 8 "github.com/ActiveState/cli/internal/testhelpers/tagsuite" 9 ) 10 11 type BundleIntegrationTestSuite struct { 12 tagsuite.Suite 13 } 14 15 func (suite *BundleIntegrationTestSuite) TestBundle_listingSimple() { 16 suite.OnlyRunForTags(tagsuite.Bundle) 17 ts := e2e.New(suite.T(), false) 18 defer ts.Close() 19 20 suite.PrepareActiveStateYAML(ts) 21 22 cp := ts.Spawn("bundles") 23 cp.Expect("Name") 24 cp.Expect("Desktop-Installer-Tools") 25 cp.ExpectExitCode(0) 26 } 27 28 func (suite *BundleIntegrationTestSuite) TestBundle_project_name_noData() { 29 suite.OnlyRunForTags(tagsuite.Bundle) 30 ts := e2e.New(suite.T(), false) 31 defer ts.Close() 32 33 cp := ts.Spawn("bundles", "--namespace", "ActiveState/Perl-5.32", "--bundle", "Temp") 34 cp.Expect("The project has no bundles to list.") 35 cp.ExpectExitCode(0) 36 } 37 38 func (suite *BundleIntegrationTestSuite) TestBundle_searchSimple() { 39 suite.OnlyRunForTags(tagsuite.Bundle) 40 ts := e2e.New(suite.T(), false) 41 defer ts.Close() 42 suite.PrepareActiveStateYAML(ts) 43 44 // Note that the expected strings might change due to inventory changes 45 cp := ts.Spawn("bundles", "search", "Ut") 46 expectations := []string{ 47 "Name", 48 "Utilities", 49 "1.00", 50 } 51 for _, expectation := range expectations { 52 cp.Expect(expectation) 53 } 54 cp.Send("q") 55 cp.ExpectExitCode(0) 56 } 57 58 func (suite *BundleIntegrationTestSuite) PrepareActiveStateYAML(ts *e2e.Session) { 59 ts.PrepareProject("ActiveState-CLI-Testing/Perl-5.32", "3cbcdcba-df34-49ea-81d0-f1385603037d") 60 } 61 62 func (suite *BundleIntegrationTestSuite) TestJSON() { 63 suite.OnlyRunForTags(tagsuite.Bundle, tagsuite.JSON) 64 ts := e2e.New(suite.T(), false) 65 defer ts.Close() 66 67 cp := ts.Spawn("bundles", "search", "Email", "--language", "Perl", "-o", "json") 68 cp.Expect(`"Name":"Email"`) 69 cp.ExpectExitCode(0) 70 AssertValidJSON(suite.T(), cp) 71 72 cp = ts.SpawnWithOpts( 73 e2e.OptArgs("checkout", "ActiveState-CLI/Bundles", "."), 74 e2e.OptAppendEnv("ACTIVESTATE_CLI_DISABLE_RUNTIME=false"), 75 ) 76 cp.Expect("Checked out project") 77 cp.ExpectExitCode(0) 78 79 cp = ts.SpawnWithOpts( 80 e2e.OptArgs("bundles", "install", "Testing", "--output", "json"), 81 ) 82 cp.Expect(`"name":"Testing"`) 83 cp.ExpectExitCode(0) 84 AssertValidJSON(suite.T(), cp) 85 86 cp = ts.SpawnWithOpts( 87 e2e.OptArgs("bundles", "uninstall", "Testing", "-o", "editor"), 88 ) 89 cp.Expect(`"name":"Testing"`) 90 cp.ExpectExitCode(0) 91 AssertValidJSON(suite.T(), cp) 92 } 93 94 func TestBundleIntegrationTestSuite(t *testing.T) { 95 suite.Run(t, new(BundleIntegrationTestSuite)) 96 }