diff --git a/brew/brew.go b/brew/brew.go index ab27856bc..79d776e73 100644 --- a/brew/brew.go +++ b/brew/brew.go @@ -24,11 +24,9 @@ const formulae = `class {{ .Name }} < Formula bin.install "{{ .BinaryName }}" end - {{ if .Caveats }} - def caveats + {{ if .Caveats }}def caveats "{{ .Caveats }}" - end - {{ end }} + end{{ end }} end ` diff --git a/brew/brew_test.go b/brew/brew_test.go index 18d766066..91a152303 100644 --- a/brew/brew_test.go +++ b/brew/brew_test.go @@ -4,8 +4,6 @@ import ( "testing" "github.com/stretchr/testify/assert" - "os" - "io/ioutil" ) func TestNameWithDash(t *testing.T) { @@ -20,6 +18,22 @@ func TestSimpleName(t *testing.T) { assert.Equal(t, formulaNameFor("binary"), "Binary") } +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 +` func TestFormulae(t *testing.T) { assert := assert.New(t) @@ -33,8 +47,6 @@ func TestFormulae(t *testing.T) { Caveats: "Here are some caveats", }) assert.NoError(err) - f, err := os.Open("./brew/test_files/test.txt") - bts, _ := ioutil.ReadAll(f) assert.NoError(err) - assert.Equal(string(bts), out.String()) + assert.Equal(testFormulaeExpected, out.String()) } diff --git a/brew/test_files/test.txt b/brew/test_files/test.txt deleted file mode 100644 index c362f18a0..000000000 --- a/brew/test_files/test.txt +++ /dev/null @@ -1,17 +0,0 @@ -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