1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-08 03:31:59 +02:00
goreleaser/config/config_test.go

58 lines
1.2 KiB
Go
Raw Normal View History

2017-05-11 04:34:47 +02:00
package config
import (
2017-05-18 14:02:44 +02:00
"fmt"
2017-05-18 14:02:02 +02:00
"io/ioutil"
"os"
"path/filepath"
2017-05-11 04:34:47 +02:00
"strings"
2017-05-11 04:35:44 +02:00
"testing"
2017-05-11 04:34:47 +02:00
2017-05-11 04:35:44 +02:00
"github.com/stretchr/testify/assert"
2017-05-11 04:34:47 +02:00
)
func TestRepo(t *testing.T) {
var assert = assert.New(t)
r := Repo{"goreleaser", "godownloader"}
assert.Equal("goreleaser/godownloader", r.String(), "not equal")
}
func TestLoadReader(t *testing.T) {
2017-05-11 04:35:44 +02:00
var conf = `
2017-05-11 04:34:47 +02:00
homepage: &homepage http://goreleaser.github.io
fpm:
homepage: *homepage
`
2017-05-11 04:35:44 +02:00
var assert = assert.New(t)
2017-05-11 04:34:47 +02:00
buf := strings.NewReader(conf)
prop, err := LoadReader(buf)
assert.Nil(err)
assert.Equal("http://goreleaser.github.io", prop.FPM.Homepage, "yaml did not load correctly")
}
2017-05-18 14:02:02 +02:00
type errorReader struct{}
func (errorReader) Read(p []byte) (n int, err error) {
return 1, fmt.Errorf("error")
}
func TestLoadBadReader(t *testing.T) {
var assert = assert.New(t)
_, err := LoadReader(errorReader{})
assert.Error(err)
}
func TestFile(t *testing.T) {
var assert = assert.New(t)
f, err := ioutil.TempFile(os.TempDir(), "config")
assert.NoError(err)
_, err = Load(filepath.Join(f.Name()))
assert.NoError(err)
}
func TestFileNotFound(t *testing.T) {
var assert = assert.New(t)
_, err := Load("/nope/no-way.yml")
assert.Error(err)
}