1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-06 03:13:48 +02:00

added fpm tests

This commit is contained in:
Carlos Alexandro Becker 2017-04-15 15:41:41 -03:00
parent 6b11beb4ee
commit 8a5392cdf0
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
2 changed files with 77 additions and 2 deletions

View File

@ -1,11 +1,13 @@
language: go
go: 1.8
install: make setup
install:
- make setup
- gem install fpm
script:
- make test
after_success:
- go get github.com/mattn/goveralls
- goveralls -coverprofile=coverage.out -service=travis-ci -repotoken="$COVERALLS_TOKEN"
- test -n "$TRAVIS_TAG" && gem install fpm && go run main.go
- test -n "$TRAVIS_TAG" && go run main.go
notifications:
email: false

73
pipeline/fpm/fpm_test.go Normal file
View File

@ -0,0 +1,73 @@
package fpm
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
"github.com/goreleaser/goreleaser/config"
"github.com/goreleaser/goreleaser/context"
"github.com/stretchr/testify/assert"
)
func TestDescription(t *testing.T) {
assert.NotEmpty(t, Pipe{}.Description())
}
func TestRunPipeNoFormats(t *testing.T) {
var assert = assert.New(t)
var ctx = &context.Context{
Config: config.Project{},
}
assert.NoError(Pipe{}.Run(ctx))
}
func TestRunPipe(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))
_, err = os.Create(filepath.Join(dist, "mybin", "mybin"))
assert.NoError(err)
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"},
Dependencies: []string{"make"},
Conflicts: []string{"git"},
},
},
}
assert.NoError(Pipe{}.Run(ctx))
}
func TestNoFPMInPath(t *testing.T) {
var assert = assert.New(t)
var path = os.Getenv("PATH")
defer func() {
assert.NoError(os.Setenv("PATH", path))
}()
os.Setenv("PATH", "")
var ctx = &context.Context{
Config: config.Project{
FPM: config.FPM{
Formats: []string{"deb"},
},
},
}
assert.EqualError(Pipe{}.Run(ctx), ErrNoFPM.Error())
}