github.com/zaquestion/lab@v0.25.1/cmd/project_list_test.go (about)

     1  package cmd
     2  
     3  import (
     4  	"os/exec"
     5  	"strings"
     6  	"testing"
     7  
     8  	"github.com/stretchr/testify/assert"
     9  	"github.com/stretchr/testify/require"
    10  )
    11  
    12  func Test_projectList(t *testing.T) {
    13  	t.Parallel()
    14  	repo := copyTestRepo(t)
    15  	cmd := exec.Command(labBinaryPath, "project", "list", "-m")
    16  	cmd.Dir = repo
    17  
    18  	b, err := cmd.CombinedOutput()
    19  	if err != nil {
    20  		t.Fatal(err)
    21  	}
    22  	projects := strings.Split(string(b), "\n")
    23  	t.Log(projects)
    24  	require.Equal(t, "lab-testing/www-gitlab-com", projects[0])
    25  }
    26  
    27  func Test_projectList_many(t *testing.T) {
    28  	t.Parallel()
    29  	repo := copyTestRepo(t)
    30  	cmd := exec.Command(labBinaryPath, "project", "list", "-n", "101")
    31  	cmd.Dir = repo
    32  
    33  	b, err := cmd.CombinedOutput()
    34  	if err != nil {
    35  		t.Fatal(err)
    36  	}
    37  
    38  	projects := getAppOutput(b)
    39  	assert.Equal(t, 101, len(projects), "Expected 101 projects listed")
    40  	assert.NotContains(t, projects, "PASS")
    41  }