From d04efee12da0219ee84b9b2be982024c1a271ee3 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Sat, 22 Apr 2017 10:41:58 -0300 Subject: [PATCH] fixing a bug int the fpm pipe, added more tests --- pipeline/fpm/fpm.go | 2 +- pipeline/fpm/fpm_test.go | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/pipeline/fpm/fpm.go b/pipeline/fpm/fpm.go index a3e58da0a..70bdebbac 100644 --- a/pipeline/fpm/fpm.go +++ b/pipeline/fpm/fpm.go @@ -56,7 +56,7 @@ func (Pipe) Run(ctx *context.Context) error { func create(ctx *context.Context, format, archive, arch string) error { var path = filepath.Join(ctx.Config.Dist, archive) - var file = path + ".deb" + var file = path + "." + format var name = ctx.Config.Build.Binary log.Println("Creating", file) diff --git a/pipeline/fpm/fpm_test.go b/pipeline/fpm/fpm_test.go index ba34ac16e..49f0ca59e 100644 --- a/pipeline/fpm/fpm_test.go +++ b/pipeline/fpm/fpm_test.go @@ -76,3 +76,31 @@ func TestNoFPMInPath(t *testing.T) { } assert.EqualError(Pipe{}.Run(ctx), ErrNoFPM.Error()) } + +func TestCreateFileDoesntExist(t *testing.T) { + var assert = assert.New(t) + folder, err := ioutil.TempDir("", "archivetest") + assert.NoError(err) + var dist = filepath.Join(folder, "dist") + assert.NoError(os.Mkdir(dist, 0755)) + assert.NoError(os.Mkdir(filepath.Join(dist, "mybin"), 0755)) + var ctx = &context.Context{ + Archives: map[string]string{ + "linuxamd64": "mybin", + }, + Config: config.Project{ + Dist: dist, + Build: config.Build{ + Goarch: []string{ + "amd64", + "i386", + }, + Binary: "mybin", + }, + FPM: config.FPM{ + Formats: []string{"deb"}, + }, + }, + } + assert.Error(Pipe{}.Run(ctx)) +}