1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-02-07 13:31:37 +02:00
goreleaser/brew/brew_test.go

53 lines
1.2 KiB
Go
Raw Normal View History

2016-12-29 10:55:35 -02:00
package brew
import (
"testing"
2016-12-29 10:56:51 -02:00
"github.com/stretchr/testify/assert"
2016-12-29 10: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 13:14:52 -02:00
2016-12-29 13:19:03 -02:00
var testFormulaeExpected = `class Test < Formula
desc "Some desc"
homepage "https://google.com"
url "https://github.com/caarlos0/test/releases/download/v0.1.3/test_#{%x(uname -s).gsub(/\n/, '')}_#{%x(uname -m).gsub(/\n/, '')}.tar.gz"
head "https://github.com/caarlos0/test.git"
version "v0.1.3"
def install
bin.install "test"
end
def caveats
"Here are some caveats"
end
end
`
2016-12-29 13:14:52 -02:00
func TestFormulae(t *testing.T) {
assert := assert.New(t)
out, err := buildFormulae(templateData{
BinaryName: "test",
Desc: "Some desc",
Homepage: "https://google.com",
Name: "Test",
Repo: "caarlos0/test",
Tag: "v0.1.3",
Caveats: "Here are some caveats",
})
assert.NoError(err)
assert.NoError(err)
2016-12-29 13:19:03 -02:00
assert.Equal(testFormulaeExpected, out.String())
2016-12-29 13:14:52 -02:00
}