1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00
goreleaser/pipeline/git/git_test.go
Carlos Alexandro Becker e39dfa1ce9
Revert "trying with test fixtures"
This reverts commit 0b7936eb0d.
2017-04-15 14:00:29 -03:00

75 lines
2.1 KiB
Go

package git
import (
"io/ioutil"
"os/exec"
"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 TestValidVersion(t *testing.T) {
var assert = assert.New(t)
var ctx = &context.Context{
Config: config.Project{},
}
assert.NoError(Pipe{}.Run(ctx))
assert.NotEmpty(ctx.Git.CurrentTag)
assert.NotEmpty(ctx.Git.PreviousTag)
assert.NotEmpty(ctx.Git.Diff)
}
func TestNotAGitFolder(t *testing.T) {
var assert = assert.New(t)
folder, err := ioutil.TempDir("", "gorelasertest")
assert.NoError(err)
var ctx = &context.Context{
Config: config.Project{},
}
assert.Error(Pipe{}.doRun(ctx, folder))
}
func TestSingleCommit(t *testing.T) {
var assert = assert.New(t)
folder, err := ioutil.TempDir("", "gorelasertest")
assert.NoError(err)
assert.NoError(exec.Command("git", "-C", folder, "init").Run())
assert.NoError(exec.Command("git", "-C", folder, "commit", "--allow-empty", "-m", "asd").Run())
assert.NoError(exec.Command("git", "-C", folder, "tag", "v0.0.1").Run())
var ctx = &context.Context{
Config: config.Project{},
}
assert.NoError(Pipe{}.doRun(ctx, folder))
}
func TestNewRepository(t *testing.T) {
var assert = assert.New(t)
folder, err := ioutil.TempDir("", "gorelasertest")
assert.NoError(err)
assert.NoError(exec.Command("git", "-C", folder, "init").Run())
var ctx = &context.Context{
Config: config.Project{},
}
assert.Error(Pipe{}.doRun(ctx, folder))
}
func TestInvalidTagFormat(t *testing.T) {
var assert = assert.New(t)
folder, err := ioutil.TempDir("", "gorelasertest")
assert.NoError(err)
assert.NoError(exec.Command("git", "-C", folder, "init").Run())
assert.NoError(exec.Command("git", "-C", folder, "commit", "--allow-empty", "-m", "asd").Run())
assert.NoError(exec.Command("git", "-C", folder, "tag", "sadasd").Run())
var ctx = &context.Context{
Config: config.Project{},
}
assert.EqualError(Pipe{}.doRun(ctx, folder), "sadasd is not in a valid version format")
}