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

     1  package cmd
     2  
     3  import (
     4  	"os/exec"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/assert"
     8  )
     9  
    10  func Test_ciArtifacts(t *testing.T) {
    11  	t.Parallel()
    12  	repo := copyTestRepo(t)
    13  	cmd := exec.Command("git", "fetch", "origin")
    14  	cmd.Dir = repo
    15  	if b, err := cmd.CombinedOutput(); err != nil {
    16  		t.Log(string(b))
    17  		t.Fatal(err)
    18  	}
    19  
    20  	cmd = exec.Command(labBinaryPath, "ci", "artifacts", "origin", "master:build3:artifacts")
    21  	cmd.Dir = repo
    22  
    23  	b, err := cmd.CombinedOutput()
    24  	if err != nil {
    25  		t.Log(string(b))
    26  		t.Fatal(err)
    27  	}
    28  	out := string(b)
    29  	assert.Contains(t, out, "Downloaded artifacts.zip")
    30  }
    31  
    32  func Test_ciArtifactsPath(t *testing.T) {
    33  	t.Parallel()
    34  	repo := copyTestRepo(t)
    35  	cmd := exec.Command("git", "fetch", "origin")
    36  	cmd.Dir = repo
    37  	if b, err := cmd.CombinedOutput(); err != nil {
    38  		t.Log(string(b))
    39  		t.Fatal(err)
    40  	}
    41  
    42  	cmd = exec.Command(labBinaryPath, "ci", "artifacts", "-p", "artifact", "origin", "master:build3:artifacts")
    43  	cmd.Dir = repo
    44  
    45  	b, err := cmd.CombinedOutput()
    46  	if err != nil {
    47  		t.Log(string(b))
    48  		t.Fatal(err)
    49  	}
    50  	out := string(b)
    51  	assert.Contains(t, out, "Downloaded artifact")
    52  }