2017-04-19 21:59:26 +02:00
|
|
|
package release
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/goreleaser/goreleaser/context"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2017-04-19 22:12:12 +02:00
|
|
|
func TestDescribeBody(t *testing.T) {
|
2017-04-19 21:59:26 +02:00
|
|
|
var assert = assert.New(t)
|
|
|
|
var changelog = "\nfeature1: description\nfeature2: other description"
|
|
|
|
var ctx = &context.Context{
|
2017-04-19 22:05:10 +02:00
|
|
|
ReleaseNotes: changelog,
|
2017-04-19 21:59:26 +02:00
|
|
|
}
|
2017-04-19 22:12:12 +02:00
|
|
|
out, err := describeBody(ctx)
|
2017-04-19 21:59:26 +02:00
|
|
|
assert.NoError(err)
|
|
|
|
assert.Contains(out.String(), changelog)
|
|
|
|
assert.Contains(out.String(), "Automated with @goreleaser")
|
|
|
|
assert.Contains(out.String(), "Built with go version go1.8")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestGoVersionFails(t *testing.T) {
|
|
|
|
var assert = assert.New(t)
|
|
|
|
var path = os.Getenv("PATH")
|
|
|
|
defer func() {
|
|
|
|
assert.NoError(os.Setenv("PATH", path))
|
|
|
|
}()
|
2017-04-21 20:45:56 +02:00
|
|
|
assert.NoError(os.Setenv("PATH", ""))
|
2017-04-19 21:59:26 +02:00
|
|
|
var ctx = &context.Context{
|
2017-04-19 22:05:10 +02:00
|
|
|
ReleaseNotes: "changelog",
|
2017-04-19 21:59:26 +02:00
|
|
|
}
|
2017-04-19 22:12:12 +02:00
|
|
|
_, err := describeBody(ctx)
|
2017-04-19 21:59:26 +02:00
|
|
|
assert.Error(err)
|
|
|
|
}
|