github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/test/integration/info_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 InfoIntegrationTestSuite struct {
    12  	tagsuite.Suite
    13  }
    14  
    15  func (suite *InfoIntegrationTestSuite) TestInfo_LatestVersion() {
    16  	suite.OnlyRunForTags(tagsuite.Info)
    17  	ts := e2e.New(suite.T(), false)
    18  	defer ts.Close()
    19  
    20  	cp := ts.Spawn("info", "pylint", "--language", "python")
    21  	cp.Expect("Package Information")
    22  	cp.Expect("Author")
    23  	cp.Expect("Version(s) Available")
    24  	cp.ExpectExitCode(0)
    25  }
    26  
    27  func (suite *InfoIntegrationTestSuite) TestInfo_SpecificVersion() {
    28  	suite.OnlyRunForTags(tagsuite.Info)
    29  	ts := e2e.New(suite.T(), false)
    30  	defer ts.Close()
    31  
    32  	cp := ts.Spawn("info", "pylint@0.28.0", "--language", "python")
    33  	cp.Expect("Package Information: pylint@0.28.0")
    34  	cp.Expect("Author")
    35  	cp.Expect("Logilab")
    36  	cp.ExpectExitCode(0)
    37  }
    38  
    39  func (suite *InfoIntegrationTestSuite) TestInfo_UnavailableVersion() {
    40  	suite.OnlyRunForTags(tagsuite.Info)
    41  	ts := e2e.New(suite.T(), false)
    42  	defer ts.Close()
    43  
    44  	cp := ts.Spawn("info", "pylint@9.9.9", "--language", "python")
    45  	cp.Expect("Could not find version 9.9.9 for package pylint")
    46  	cp.ExpectExitCode(1)
    47  	ts.IgnoreLogErrors()
    48  }
    49  
    50  func (suite *InfoIntegrationTestSuite) TestJSON() {
    51  	suite.OnlyRunForTags(tagsuite.Info, tagsuite.JSON)
    52  	ts := e2e.New(suite.T(), false)
    53  	defer ts.Close()
    54  
    55  	cp := ts.Spawn("info", "pylint", "--language", "python", "-o", "json")
    56  	cp.Expect(`"description":`)
    57  	cp.Expect(`"authors":`)
    58  	cp.Expect(`"version":`)
    59  	cp.ExpectExitCode(0)
    60  	//AssertValidJSON(suite.T(), cp)
    61  
    62  	cp = ts.Spawn("info", "pylint@9.9.9", "--language", "python", "--output", "editor")
    63  	cp.Expect(`"error":`)
    64  	cp.ExpectExitCode(1)
    65  	AssertValidJSON(suite.T(), cp)
    66  	ts.IgnoreLogErrors()
    67  }
    68  
    69  func TestInfoIntegrationTestSuite(t *testing.T) {
    70  	suite.Run(t, new(InfoIntegrationTestSuite))
    71  }