1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-17 20:47:50 +02:00

Merge pull request #309 from goreleaser/brew-test

Improved brew formulas, added more tests
This commit is contained in:
Carlos Alexandro Becker 2017-07-16 16:09:00 -03:00 committed by GitHub
commit 41f3b17441
3 changed files with 62 additions and 3 deletions

View File

@ -109,11 +109,15 @@ func dataFor(ctx *context.Context, client client.Client, folder string) (result
Dependencies: ctx.Config.Brew.Dependencies,
Conflicts: ctx.Config.Brew.Conflicts,
Plist: ctx.Config.Brew.Plist,
Install: strings.Split(ctx.Config.Brew.Install, "\n"),
Tests: strings.Split(ctx.Config.Brew.Test, "\n"),
Install: split(ctx.Config.Brew.Install),
Tests: split(ctx.Config.Brew.Test),
}, nil
}
func split(s string) []string {
return strings.Split(strings.TrimSpace(s), "\n")
}
func formulaNameFor(name string) string {
name = strings.Replace(name, "-", " ", -1)
name = strings.Replace(name, "_", " ", -1)

View File

@ -83,13 +83,24 @@ func TestFormulaeSimple(t *testing.T) {
assert.NotContains(formulae, "def plist;")
}
func TestSplit(t *testing.T) {
var assert = assert.New(t)
var parts = split("system \"true\"\nsystem \"#{bin}/foo -h\"")
assert.Equal([]string{"system \"true\"", "system \"#{bin}/foo -h\""}, parts)
}
func TestRunPipe(t *testing.T) {
assert := assert.New(t)
folder, err := ioutil.TempDir("", "goreleasertest")
assert.NoError(err)
var ctx = &context.Context{
Git: context.GitInfo{
CurrentTag: "v1.0.1",
},
Version: "1.0.1",
Config: config.Project{
Dist: folder,
Dist: folder,
ProjectName: "run-pipe",
Archive: config.Archive{
Format: "tar.gz",
},
@ -98,6 +109,14 @@ func TestRunPipe(t *testing.T) {
Owner: "test",
Name: "test",
},
Description: "A run pipe test formula",
Homepage: "https://github.com/goreleaser",
Caveats: "don't do this",
Test: "system \"true\"\nsystem \"#{bin}/foo -h\"",
Plist: `<xml>whatever</xml>`,
Dependencies: []string{"zsh"},
Conflicts: []string{"gtk+"},
Install: `bin.install "foo"`,
},
},
Publish: true,
@ -112,6 +131,12 @@ func TestRunPipe(t *testing.T) {
assert.NoError(err)
assert.NoError(doRun(ctx, client))
assert.True(client.CreatedFile)
f, err := os.Open("testdata/run_pipe.rb")
assert.NoError(err)
bts, err := ioutil.ReadAll(f)
assert.NoError(err)
assert.Equal(string(bts), client.Content)
}
func TestRunPipeFormatOverride(t *testing.T) {

30
pipeline/brew/testdata/run_pipe.rb vendored Normal file
View File

@ -0,0 +1,30 @@
class RunPipe < Formula
desc "A run pipe test formula"
homepage "https://github.com/goreleaser"
url "https://github.com///releases/download/v1.0.1/bin.tar.gz"
version "1.0.1"
sha256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
depends_on "zsh"
conflicts_with "gtk+"
def install
bin.install "foo"
end
def caveats
"don't do this"
end
plist_options :startup => false
def plist; <<-EOS.undent
<xml>whatever</xml>
EOS
end
test do
system "true"
system "#{bin}/foo -h"
end
end