tests: Convert from testify to quicktest

This commit is contained in:
Bjørn Erik Pedersen
2019-08-10 21:05:17 +02:00
parent 6027ee1108
commit 9e57182705
195 changed files with 3919 additions and 3693 deletions

View File

@@ -16,19 +16,20 @@ package releaser
import (
"testing"
"github.com/stretchr/testify/require"
qt "github.com/frankban/quicktest"
)
func TestGitInfos(t *testing.T) {
c := qt.New(t)
skipIfCI(t)
infos, err := getGitInfos("v0.20", "hugo", "", false)
require.NoError(t, err)
require.True(t, len(infos) > 0)
c.Assert(err, qt.IsNil)
c.Assert(len(infos) > 0, qt.Equals, true)
}
func TestIssuesRe(t *testing.T) {
c := qt.New(t)
body := `
This is a commit message.
@@ -41,28 +42,30 @@ See #456
issues := extractIssues(body)
require.Len(t, issues, 4)
require.Equal(t, 123, issues[0])
require.Equal(t, 543, issues[2])
c.Assert(len(issues), qt.Equals, 4)
c.Assert(issues[0], qt.Equals, 123)
c.Assert(issues[2], qt.Equals, 543)
}
func TestGitVersionTagBefore(t *testing.T) {
skipIfCI(t)
c := qt.New(t)
v1, err := gitVersionTagBefore("v0.18")
require.NoError(t, err)
require.Equal(t, "v0.17", v1)
c.Assert(err, qt.IsNil)
c.Assert(v1, qt.Equals, "v0.17")
}
func TestTagExists(t *testing.T) {
skipIfCI(t)
c := qt.New(t)
b1, err := tagExists("v0.18")
require.NoError(t, err)
require.True(t, b1)
c.Assert(err, qt.IsNil)
c.Assert(b1, qt.Equals, true)
b2, err := tagExists("adfagdsfg")
require.NoError(t, err)
require.False(t, b2)
c.Assert(err, qt.IsNil)
c.Assert(b2, qt.Equals, false)
}

View File

@@ -18,22 +18,24 @@ import (
"os"
"testing"
"github.com/stretchr/testify/require"
qt "github.com/frankban/quicktest"
)
func TestGitHubLookupCommit(t *testing.T) {
skipIfNoToken(t)
c := qt.New(t)
client := newGitHubAPI("hugo")
commit, err := client.fetchCommit("793554108763c0984f1a1b1a6ee5744b560d78d0")
require.NoError(t, err)
c.Assert(err, qt.IsNil)
fmt.Println(commit)
}
func TestFetchRepo(t *testing.T) {
skipIfNoToken(t)
c := qt.New(t)
client := newGitHubAPI("hugo")
repo, err := client.fetchRepo()
require.NoError(t, err)
c.Assert(err, qt.IsNil)
fmt.Println(">>", len(repo.Contributors))
}

View File

@@ -22,7 +22,7 @@ import (
"os"
"testing"
"github.com/stretchr/testify/require"
qt "github.com/frankban/quicktest"
)
func _TestReleaseNotesWriter(t *testing.T) {
@@ -30,14 +30,15 @@ func _TestReleaseNotesWriter(t *testing.T) {
// Travis has an ancient git with no --invert-grep: https://github.com/travis-ci/travis-ci/issues/6328
t.Skip("Skip git test on CI to make Travis happy.")
}
c := qt.New(t)
var b bytes.Buffer
// TODO(bep) consider to query GitHub directly for the gitlog with author info, probably faster.
infos, err := getGitInfosBefore("HEAD", "v0.20", "hugo", "", false)
require.NoError(t, err)
c.Assert(err, qt.IsNil)
require.NoError(t, writeReleaseNotes("0.21", infos, infos, &b))
c.Assert(writeReleaseNotes("0.21", infos, infos, &b), qt.IsNil)
fmt.Println(b.String())