1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-24 04:16:27 +02:00
goreleaser/pipeline/release/release_test.go

81 lines
1.7 KiB
Go
Raw Normal View History

2016-12-29 11:21:50 -02:00
package release
import (
2017-03-26 15:56:35 -03:00
"bytes"
"io/ioutil"
"os"
"path/filepath"
2016-12-30 12:03:43 -02:00
"testing"
2017-01-02 10:47:19 -02:00
2017-03-26 15:56:35 -03:00
"github.com/goreleaser/goreleaser/clients"
"github.com/goreleaser/goreleaser/config"
"github.com/goreleaser/goreleaser/context"
2017-01-02 10:47:19 -02:00
"github.com/stretchr/testify/assert"
2016-12-29 11:21:50 -02:00
)
2017-03-25 20:46:02 -03:00
func TestPipeDescription(t *testing.T) {
2017-03-25 20:43:42 -03:00
assert.NotEmpty(t, Pipe{}.Description())
}
2017-03-26 15:56:35 -03:00
func TestRunPipe(t *testing.T) {
assert := assert.New(t)
folder, err := ioutil.TempDir("", "gorelasertest")
assert.NoError(err)
_, err = os.Create(filepath.Join(folder, "bin.tar.gz"))
assert.NoError(err)
_, err = os.Create(filepath.Join(folder, "bin.deb"))
assert.NoError(err)
var ctx = &context.Context{
Git: context.GitInfo{
CurrentTag: "v1.0.0",
},
Config: config.Project{
Dist: folder,
Archive: config.Archive{
Format: "tar.gz",
},
Release: config.Release{
GitHub: config.Repo{
Owner: "test",
Name: "test",
},
},
FPM: config.FPM{
Formats: []string{
"deb",
},
},
},
Archives: map[string]string{
"darwinamd64": "bin",
},
}
client := &DummyClient{}
assert.NoError(doRun(ctx, client))
assert.True(client.CreatedRelease)
assert.True(client.UploadedFile)
}
type DummyClient struct {
CreatedRelease bool
UploadedFile bool
}
func (client *DummyClient) GetInfo(ctx *context.Context) (info clients.Info, err error) {
return
}
func (client *DummyClient) CreateRelease(ctx *context.Context) (releaseID int, err error) {
client.CreatedRelease = true
return
}
func (client *DummyClient) CreateFile(ctx *context.Context, content bytes.Buffer, path string) (err error) {
return
}
func (client *DummyClient) Upload(ctx *context.Context, releaseID int, name string, file *os.File) (err error) {
client.UploadedFile = true
return
}