github.com/client9/goreleaser@v0.17.4-0.20170511023544-27e4b028926d/pipeline/release/body_test.go (about)

     1  package release
     2  
     3  import (
     4  	"os"
     5  	"testing"
     6  
     7  	"github.com/goreleaser/goreleaser/context"
     8  	"github.com/stretchr/testify/assert"
     9  )
    10  
    11  func TestDescribeBody(t *testing.T) {
    12  	var assert = assert.New(t)
    13  	var changelog = "\nfeature1: description\nfeature2: other description"
    14  	var ctx = &context.Context{
    15  		ReleaseNotes: changelog,
    16  	}
    17  	out, err := describeBody(ctx)
    18  	assert.NoError(err)
    19  	assert.Contains(out.String(), changelog)
    20  	assert.Contains(out.String(), "Automated with @goreleaser")
    21  	assert.Contains(out.String(), "Built with go version go1.8")
    22  }
    23  
    24  func TestGoVersionFails(t *testing.T) {
    25  	var assert = assert.New(t)
    26  	var path = os.Getenv("PATH")
    27  	defer func() {
    28  		assert.NoError(os.Setenv("PATH", path))
    29  	}()
    30  	assert.NoError(os.Setenv("PATH", ""))
    31  	var ctx = &context.Context{
    32  		ReleaseNotes: "changelog",
    33  	}
    34  	_, err := describeBody(ctx)
    35  	assert.Error(err)
    36  }