@@ -1447,12 +1447,19 @@ func TestDoGetFallback(t *testing.T) {
1447
1447
body , _ := json .Marshal (apiResp )
1448
1448
1449
1449
if req .Method == http .MethodPost {
1450
- if req .URL .Path == "/blockPost " {
1450
+ if req .URL .Path == "/blockPost405 " {
1451
1451
http .Error (w , string (body ), http .StatusMethodNotAllowed )
1452
1452
return
1453
1453
}
1454
1454
}
1455
1455
1456
+ if req .Method == http .MethodPost {
1457
+ if req .URL .Path == "/blockPost501" {
1458
+ http .Error (w , string (body ), http .StatusNotImplemented )
1459
+ return
1460
+ }
1461
+ }
1462
+
1456
1463
w .Write (body )
1457
1464
}))
1458
1465
// Close the server when test finishes.
@@ -1483,8 +1490,24 @@ func TestDoGetFallback(t *testing.T) {
1483
1490
t .Fatalf ("Mismatch in values" )
1484
1491
}
1485
1492
1486
- // Do a fallbcak to a get.
1487
- u .Path = "/blockPost"
1493
+ // Do a fallback to a get on 405.
1494
+ u .Path = "/blockPost405"
1495
+ _ , b , _ , err = api .DoGetFallback (context .TODO (), u , v )
1496
+ if err != nil {
1497
+ t .Fatalf ("Error doing local request: %v" , err )
1498
+ }
1499
+ if err := json .Unmarshal (b , resp ); err != nil {
1500
+ t .Fatal (err )
1501
+ }
1502
+ if resp .Method != http .MethodGet {
1503
+ t .Fatalf ("Mismatch method" )
1504
+ }
1505
+ if resp .Values != v .Encode () {
1506
+ t .Fatalf ("Mismatch in values" )
1507
+ }
1508
+
1509
+ // Do a fallback to a get on 501.
1510
+ u .Path = "/blockPost501"
1488
1511
_ , b , _ , err = api .DoGetFallback (context .TODO (), u , v )
1489
1512
if err != nil {
1490
1513
t .Fatalf ("Error doing local request: %v" , err )
0 commit comments