Skip to content

Commit e84cc9e

Browse files
committed
tests: tidy up gitutil testing structs
Signed-off-by: Justin Chadwell <[email protected]>
1 parent 892dedf commit e84cc9e

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

util/gitutil/git_protocol_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ func TestParseProtocol(t *testing.T) {
4444
},
4545
}
4646
for _, test := range tests {
47-
remote, protocol := ParseProtocol(test.url)
48-
require.Equal(t, remote, test.remote)
49-
require.Equal(t, protocol, test.protocol)
47+
t.Run(test.url, func(t *testing.T) {
48+
protocol, remote, path := ParseProtocol(test.url)
49+
require.Equal(t, test.protocol, protocol)
50+
require.Equal(t, test.remote, remote)
51+
})
5052
}
5153
}

util/gitutil/git_ref_test.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package gitutil
22

33
import (
4-
"reflect"
54
"testing"
5+
6+
"github.com/stretchr/testify/require"
67
)
78

89
func TestParseGitRef(t *testing.T) {
@@ -124,16 +125,10 @@ func TestParseGitRef(t *testing.T) {
124125
t.Run(tt.ref, func(t *testing.T) {
125126
got, err := ParseGitRef(tt.ref)
126127
if tt.expected == nil {
127-
if err == nil {
128-
t.Errorf("expected an error for ParseGitRef(%q)", tt.ref)
129-
}
128+
require.Error(t, err)
130129
} else {
131-
if err != nil {
132-
t.Errorf("got an unexpected error: ParseGitRef(%q): %v", tt.ref, err)
133-
}
134-
if !reflect.DeepEqual(got, tt.expected) {
135-
t.Errorf("expected ParseGitRef(%q) to return %#v, got %#v", tt.ref, tt.expected, got)
136-
}
130+
require.NoError(t, err)
131+
require.Equal(t, tt.expected, got)
137132
}
138133
})
139134
}

0 commit comments

Comments
 (0)