1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00
goreleaser/pipeline/brew/brew_test.go

64 lines
1.8 KiB
Go
Raw Normal View History

2016-12-29 14:55:35 +02:00
package brew
import (
"testing"
2016-12-29 14:56:51 +02:00
2017-01-06 15:13:17 +02:00
"github.com/stretchr/testify/assert"
2016-12-29 14:55:35 +02:00
)
func TestNameWithDash(t *testing.T) {
assert.Equal(t, formulaNameFor("some-binary"), "SomeBinary")
}
func TestNameWithUnderline(t *testing.T) {
assert.Equal(t, formulaNameFor("some_binary"), "SomeBinary")
}
func TestSimpleName(t *testing.T) {
assert.Equal(t, formulaNameFor("binary"), "Binary")
}
2016-12-29 17:14:52 +02:00
2016-12-31 21:02:25 +02:00
var defaultTemplateData = templateData{
BinaryName: "test",
Desc: "Some desc",
Homepage: "https://google.com",
Name: "Test",
Repo: "caarlos0/test",
Tag: "v0.1.3",
2017-01-11 18:28:12 +02:00
File: "test_Darwin_x86_64",
2017-01-11 18:08:29 +02:00
SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68",
2017-01-06 17:52:14 +02:00
Format: "tar.gz",
2016-12-31 21:02:25 +02:00
}
func assertDefaultTemplateData(t *testing.T, formulae string) {
assert := assert.New(t)
assert.Contains(formulae, "class Test < Formula")
assert.Contains(formulae, "homepage \"https://google.com\"")
2017-01-06 17:54:14 +02:00
assert.Contains(formulae, "url \"https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_x86_64.tar.gz\"")
2017-01-11 18:08:29 +02:00
assert.Contains(formulae, "sha256 \"1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68\"")
2016-12-31 21:02:25 +02:00
assert.Contains(formulae, "version \"v0.1.3\"")
assert.Contains(formulae, "bin.install \"test\"")
2017-01-11 18:08:29 +02:00
2016-12-31 21:02:25 +02:00
}
func TestFullFormulae(t *testing.T) {
2016-12-29 17:14:52 +02:00
assert := assert.New(t)
2016-12-31 21:02:25 +02:00
data := defaultTemplateData
data.Caveats = "Here are some caveats"
out, err := doBuildFormulae(data)
2016-12-29 17:14:52 +02:00
assert.NoError(err)
2016-12-31 21:02:25 +02:00
formulae := out.String()
assertDefaultTemplateData(t, formulae)
assert.Contains(formulae, "def caveats")
assert.Contains(formulae, "Here are some caveats")
}
func TestFormulaeNoCaveats(t *testing.T) {
assert := assert.New(t)
out, err := doBuildFormulae(defaultTemplateData)
2016-12-29 17:14:52 +02:00
assert.NoError(err)
2016-12-31 21:02:25 +02:00
formulae := out.String()
assertDefaultTemplateData(t, formulae)
assert.NotContains(formulae, "def caveats")
2016-12-29 17:14:52 +02:00
}