@@ -11,6 +11,7 @@ import (
1111 "time"
1212
1313 "github.com/replicate/replicate-go"
14+
1415 "github.com/stretchr/testify/assert"
1516 "github.com/stretchr/testify/require"
1617)
@@ -1148,19 +1149,11 @@ func TestAutomaticallyRetryGetRequests(t *testing.T) {
11481149 w .Header ().Set ("Retry-After" , "0" )
11491150 w .WriteHeader (status )
11501151
1151- if status == http .StatusInternalServerError {
1152- err := & replicate.APIError {
1153- Detail : "Internal server error" ,
1154- }
1155- body , _ := json .Marshal (err )
1156- w .Write (body )
1157- } else if status == http .StatusTooManyRequests {
1158- err := & replicate.APIError {
1159- Detail : "Too many requests" ,
1160- }
1161- body , _ := json .Marshal (err )
1162- w .Write (body )
1152+ err := replicate.APIError {
1153+ Detail : http .StatusText (status ),
11631154 }
1155+ body , _ := json .Marshal (err )
1156+ w .Write (body )
11641157 }
11651158 }))
11661159 defer mockServer .Close ()
@@ -1191,19 +1184,11 @@ func TestAutomaticallyRetryPostRequests(t *testing.T) {
11911184 w .Header ().Set ("Retry-After" , "0" )
11921185 w .WriteHeader (status )
11931186
1194- if status == http .StatusInternalServerError {
1195- err := & replicate.APIError {
1196- Detail : "Internal server error" ,
1197- }
1198- body , _ := json .Marshal (err )
1199- w .Write (body )
1200- } else if status == http .StatusTooManyRequests {
1201- err := & replicate.APIError {
1202- Detail : "Too many requests" ,
1203- }
1204- body , _ := json .Marshal (err )
1205- w .Write (body )
1187+ err := replicate.APIError {
1188+ Detail : http .StatusText (status ),
12061189 }
1190+ body , _ := json .Marshal (err )
1191+ w .Write (body )
12071192 }))
12081193 defer mockServer .Close ()
12091194
@@ -1224,7 +1209,7 @@ func TestAutomaticallyRetryPostRequests(t *testing.T) {
12241209 version := "5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa"
12251210 _ , err = client .CreatePrediction (ctx , version , input , & webhook , true )
12261211
1227- assert .ErrorContains (t , err , "Internal server error" )
1212+ assert .ErrorContains (t , err , http . StatusText ( http . StatusInternalServerError ) )
12281213}
12291214
12301215func TestStream (t * testing.T ) {
0 commit comments