Skip to content

Commit

Permalink
tests: tidy up gitutil testing structs
Browse files Browse the repository at this point in the history
Signed-off-by: Justin Chadwell <me@jedevc.com>
  • Loading branch information
jedevc committed Aug 11, 2023
1 parent f47a9da commit dc5890b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
8 changes: 5 additions & 3 deletions util/gitutil/git_protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ func TestParseProtocol(t *testing.T) {
},
}
for _, test := range tests {
remote, protocol := ParseProtocol(test.url)
require.Equal(t, remote, test.remote)
require.Equal(t, protocol, test.protocol)
t.Run(test.url, func(t *testing.T) {
protocol, remote, path := ParseProtocol(test.url)
require.Equal(t, test.protocol, protocol)
require.Equal(t, test.remote, remote)
})
}
}
15 changes: 5 additions & 10 deletions util/gitutil/git_ref_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package gitutil

import (
"reflect"
"testing"

"github.com/stretchr/testify/require"
)

func TestParseGitRef(t *testing.T) {
Expand Down Expand Up @@ -124,16 +125,10 @@ func TestParseGitRef(t *testing.T) {
t.Run(tt.ref, func(t *testing.T) {
got, err := ParseGitRef(tt.ref)
if tt.expected == nil {
if err == nil {
t.Errorf("expected an error for ParseGitRef(%q)", tt.ref)
}
require.Error(t, err)
} else {
if err != nil {
t.Errorf("got an unexpected error: ParseGitRef(%q): %v", tt.ref, err)
}
if !reflect.DeepEqual(got, tt.expected) {
t.Errorf("expected ParseGitRef(%q) to return %#v, got %#v", tt.ref, tt.expected, got)
}
require.NoError(t, err)
require.Equal(t, tt.expected, got)
}
})
}
Expand Down

0 comments on commit dc5890b

Please sign in to comment.