@@ -2,12 +2,12 @@ package api
22
33import (
44 "encoding/json"
5- "reflect"
65 "testing"
76
87 "github.com/MakeNowJust/heredoc"
98 "github.com/cli/cli/internal/ghrepo"
109 "github.com/cli/cli/pkg/httpmock"
10+ "github.com/stretchr/testify/assert"
1111)
1212
1313func TestBranchDeleteRemote (t * testing.T ) {
@@ -149,13 +149,13 @@ func Test_determinePullRequestFeatures(t *testing.T) {
149149 }
150150
151151 gotPrFeatures , err := determinePullRequestFeatures (httpClient , tt .hostname )
152- if ( err != nil ) != tt .wantErr {
153- t . Errorf ( "determinePullRequestFeatures() error = %v, wantErr %v" , err , tt . wantErr )
152+ if tt .wantErr {
153+ assert . Error ( t , err )
154154 return
155+ } else {
156+ assert .NoError (t , err )
155157 }
156- if ! reflect .DeepEqual (gotPrFeatures , tt .wantPrFeatures ) {
157- t .Errorf ("determinePullRequestFeatures() = %v, want %v" , gotPrFeatures , tt .wantPrFeatures )
158- }
158+ assert .Equal (t , tt .wantPrFeatures , gotPrFeatures )
159159 })
160160 }
161161}
@@ -168,9 +168,9 @@ func Test_Logins(t *testing.T) {
168168 want []string
169169 }{
170170 {
171- name : "no requested reviewers" ,
171+ name : "no requested reviewers" ,
172172 requestedReviews : `{"nodes": []}` ,
173- want : []string {},
173+ want : []string {},
174174 },
175175 {
176176 name : "user" ,
@@ -234,13 +234,9 @@ func Test_Logins(t *testing.T) {
234234 for _ , tt := range tests {
235235 t .Run (tt .name , func (t * testing.T ) {
236236 err := json .Unmarshal ([]byte (tt .requestedReviews ), & rr )
237- if err != nil {
238- t .Fatalf ("Failed to unmarshal json string as ReviewRequests: %v" , tt .requestedReviews )
239- }
240- got := rr .Logins ()
241- if ! reflect .DeepEqual (got , tt .want ) {
242- t .Fatalf ("Unexpected results: expected %v but got %v" , tt .want , got )
243- }
237+ assert .NoError (t , err , "Failed to unmarshal json string as ReviewRequests" )
238+ logins := rr .Logins ()
239+ assert .Equal (t , tt .want , logins )
244240 })
245241 }
246242}
0 commit comments