github.com/marianogappa/goreleaser@v0.26.2-0.20170715090149-96acd0a9fc46/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.")
    22  }
    23  
    24  func TestDontEscapeHTML(t *testing.T) {
    25  	var assert = assert.New(t)
    26  	var changelog = "<h1>test</h1>"
    27  	var ctx = &context.Context{
    28  		ReleaseNotes: changelog,
    29  	}
    30  	out, err := describeBody(ctx)
    31  	assert.NoError(err)
    32  	assert.Contains(out.String(), changelog)
    33  }
    34  
    35  func TestGoVersionFails(t *testing.T) {
    36  	var assert = assert.New(t)
    37  	var path = os.Getenv("PATH")
    38  	defer func() {
    39  		assert.NoError(os.Setenv("PATH", path))
    40  	}()
    41  	assert.NoError(os.Setenv("PATH", ""))
    42  	var ctx = &context.Context{
    43  		ReleaseNotes: "changelog",
    44  	}
    45  	_, err := describeBody(ctx)
    46  	assert.Error(err)
    47  }