@@ -193,8 +193,8 @@ func TestCreateDeleteNetwork(t *testing.T) {
193193 if errRsp == & createdResponse {
194194 t .Fatalf ("Expected to fail but succeeded" )
195195 }
196- if errRsp .StatusCode != http .StatusBadRequest {
197- t .Fatalf ("Expected StatusBadRequest status code, got: %v" , errRsp . StatusCode )
196+ if errRsp .StatusCode != http .StatusNotFound {
197+ t .Fatalf ("Expected StatusNotFound status code, got: %v" , errRsp )
198198 }
199199
200200 ops := make (map [string ]interface {})
@@ -1305,3 +1305,92 @@ func TestHttpHandlerGood(t *testing.T) {
13051305 t .Fatalf ("Incongruent resource found" )
13061306 }
13071307}
1308+
1309+ type bre struct {}
1310+
1311+ func (b * bre ) Error () string {
1312+ return "I am a bad request error"
1313+ }
1314+ func (b * bre ) BadRequest () {}
1315+
1316+ type nfe struct {}
1317+
1318+ func (n * nfe ) Error () string {
1319+ return "I am a not found error"
1320+ }
1321+ func (n * nfe ) NotFound () {}
1322+
1323+ type forb struct {}
1324+
1325+ func (f * forb ) Error () string {
1326+ return "I am a bad request error"
1327+ }
1328+ func (f * forb ) Forbidden () {}
1329+
1330+ type notimpl struct {}
1331+
1332+ func (nip * notimpl ) Error () string {
1333+ return "I am a not implemented error"
1334+ }
1335+ func (nip * notimpl ) NotImplemented () {}
1336+
1337+ type inter struct {}
1338+
1339+ func (it * inter ) Error () string {
1340+ return "I am a internal error"
1341+ }
1342+ func (it * inter ) Internal () {}
1343+
1344+ type tout struct {}
1345+
1346+ func (to * tout ) Error () string {
1347+ return "I am a timeout error"
1348+ }
1349+ func (to * tout ) Timeout () {}
1350+
1351+ type noserv struct {}
1352+
1353+ func (nos * noserv ) Error () string {
1354+ return "I am a no service error"
1355+ }
1356+ func (nos * noserv ) NoService () {}
1357+
1358+ type notclassified struct {}
1359+
1360+ func (noc * notclassified ) Error () string {
1361+ return "I am a non classified error"
1362+ }
1363+
1364+ func TestErrorConversion (t * testing.T ) {
1365+ if convertNetworkError (new (bre )).StatusCode != http .StatusBadRequest {
1366+ t .Fatalf ("Failed to recognize BadRequest error" )
1367+ }
1368+
1369+ if convertNetworkError (new (nfe )).StatusCode != http .StatusNotFound {
1370+ t .Fatalf ("Failed to recognize NotFound error" )
1371+ }
1372+
1373+ if convertNetworkError (new (forb )).StatusCode != http .StatusForbidden {
1374+ t .Fatalf ("Failed to recognize Forbidden error" )
1375+ }
1376+
1377+ if convertNetworkError (new (notimpl )).StatusCode != http .StatusNotImplemented {
1378+ t .Fatalf ("Failed to recognize NotImplemented error" )
1379+ }
1380+
1381+ if convertNetworkError (new (inter )).StatusCode != http .StatusInternalServerError {
1382+ t .Fatalf ("Failed to recognize Internal error" )
1383+ }
1384+
1385+ if convertNetworkError (new (tout )).StatusCode != http .StatusRequestTimeout {
1386+ t .Fatalf ("Failed to recognize Timeout error" )
1387+ }
1388+
1389+ if convertNetworkError (new (noserv )).StatusCode != http .StatusServiceUnavailable {
1390+ t .Fatalf ("Failed to recognize No Service error" )
1391+ }
1392+
1393+ if convertNetworkError (new (notclassified )).StatusCode != http .StatusInternalServerError {
1394+ t .Fatalf ("Failed to recognize not classified error as Internal error" )
1395+ }
1396+ }
0 commit comments