use t.Cleanup and prefer assert.NoError over .Nil (#309)
Co-authored-by: Casey Lee <cplee@nektos.com>
This commit is contained in:
parent
f00aa08417
commit
85a47838fd
1 changed files with 14 additions and 14 deletions
|
@ -35,39 +35,39 @@ func TestFindGitSlug(t *testing.T) {
|
||||||
for _, tt := range slugTests {
|
for _, tt := range slugTests {
|
||||||
provider, slug, err := findGitSlug(tt.url)
|
provider, slug, err := findGitSlug(tt.url)
|
||||||
|
|
||||||
assert.Nil(err)
|
assert.NoError(err)
|
||||||
assert.Equal(tt.provider, provider)
|
assert.Equal(tt.provider, provider)
|
||||||
assert.Equal(tt.slug, slug)
|
assert.Equal(tt.slug, slug)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testDir(t *testing.T) string {
|
||||||
|
basedir, err := ioutil.TempDir("", "act-test")
|
||||||
|
require.NoError(t, err)
|
||||||
|
t.Cleanup(func() { os.RemoveAll(basedir) })
|
||||||
|
return basedir
|
||||||
|
}
|
||||||
|
|
||||||
func TestFindGitRemoteURL(t *testing.T) {
|
func TestFindGitRemoteURL(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
basedir, err := ioutil.TempDir("", "act-test")
|
basedir := testDir(t)
|
||||||
defer os.RemoveAll(basedir)
|
|
||||||
|
|
||||||
assert.Nil(err)
|
|
||||||
|
|
||||||
gitConfig()
|
gitConfig()
|
||||||
err = gitCmd("init", basedir)
|
err := gitCmd("init", basedir)
|
||||||
assert.Nil(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
remoteURL := "https://git-codecommit.us-east-1.amazonaws.com/v1/repos/my-repo-name"
|
remoteURL := "https://git-codecommit.us-east-1.amazonaws.com/v1/repos/my-repo-name"
|
||||||
err = gitCmd("config", "-f", fmt.Sprintf("%s/.git/config", basedir), "--add", "remote.origin.url", remoteURL)
|
err = gitCmd("config", "-f", fmt.Sprintf("%s/.git/config", basedir), "--add", "remote.origin.url", remoteURL)
|
||||||
assert.Nil(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
u, err := findGitRemoteURL(basedir)
|
u, err := findGitRemoteURL(basedir)
|
||||||
assert.Nil(err)
|
assert.NoError(err)
|
||||||
assert.Equal(remoteURL, u)
|
assert.Equal(remoteURL, u)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGitFindRef(t *testing.T) {
|
func TestGitFindRef(t *testing.T) {
|
||||||
basedir, err := ioutil.TempDir("", "act-test")
|
basedir := testDir(t)
|
||||||
defer os.RemoveAll(basedir)
|
|
||||||
assert.NoError(t, err)
|
|
||||||
|
|
||||||
gitConfig()
|
gitConfig()
|
||||||
|
|
||||||
for name, tt := range map[string]struct {
|
for name, tt := range map[string]struct {
|
||||||
|
|
Loading…
Reference in a new issue