1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-07-15 01:34:21 +02:00

refactor: use require on all tests (#1839)

* refactor: use require on all tests

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

* refactor: use require on all tests

Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Carlos Alexandro Becker
2020-10-06 09:48:04 -03:00
committed by GitHub
parent 2c487bc478
commit 979f8632b7
48 changed files with 1074 additions and 1106 deletions

View File

@ -5,22 +5,22 @@ import (
"time"
"github.com/goreleaser/goreleaser/internal/git"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
// GitInit inits a new git project.
func GitInit(t *testing.T) {
out, err := fakeGit("init")
assert.NoError(t, err)
assert.Contains(t, out, "Initialized empty Git repository")
assert.NoError(t, err)
require.NoError(t, err)
require.Contains(t, out, "Initialized empty Git repository")
require.NoError(t, err)
}
// GitRemoteAdd adds the given url as remote.
func GitRemoteAdd(t *testing.T, url string) {
out, err := fakeGit("remote", "add", "origin", url)
assert.NoError(t, err)
assert.Empty(t, out)
require.NoError(t, err)
require.Empty(t, out)
}
// GitCommit creates a git commits.
@ -37,29 +37,29 @@ func GitCommitWithDate(t *testing.T, msg string, commitDate time.Time) {
}
}
out, err := fakeGitEnv(env, "commit", "--allow-empty", "-m", msg)
assert.NoError(t, err)
assert.Contains(t, out, "master", msg)
require.NoError(t, err)
require.Contains(t, out, "master", msg)
}
// GitTag creates a git tag.
func GitTag(t *testing.T, tag string) {
out, err := fakeGit("tag", tag)
assert.NoError(t, err)
assert.Empty(t, out)
require.NoError(t, err)
require.Empty(t, out)
}
// GitBranch creates a git branch.
func GitBranch(t *testing.T, branch string) {
out, err := fakeGit("branch", branch)
assert.NoError(t, err)
assert.Empty(t, out)
require.NoError(t, err)
require.Empty(t, out)
}
// GitAdd adds all files to stage.
func GitAdd(t *testing.T) {
out, err := fakeGit("add", "-A")
assert.NoError(t, err)
assert.Empty(t, out)
require.NoError(t, err)
require.Empty(t, out)
}
func fakeGitEnv(env map[string]string, args ...string) (string, error) {
@ -80,6 +80,6 @@ func fakeGit(args ...string) (string, error) {
// GitCheckoutBranch allows us to change the active branch that we're using.
func GitCheckoutBranch(t *testing.T, name string) {
out, err := fakeGit("checkout", "-b", name)
assert.NoError(t, err)
assert.Empty(t, out)
require.NoError(t, err)
require.Empty(t, out)
}