@@ -1551,3 +1551,32 @@ func TestPutPatronRequestsIdOK(t *testing.T) {
15511551 assert .NoError (t , err )
15521552 assert .Equal (t , id , response .Id )
15531553}
1554+
1555+ func TestPutPatronRequestsIdEmptyIllRequest (t * testing.T ) {
1556+ handler := NewPrApiHandler (new (PrRepoError ), mockEventBus , mockEventRepo , tenant .NewResolver (), nil , 10 )
1557+ handler .SetIllRepo (new (illRepoNoTx ))
1558+ id := "3"
1559+ body := proapi.CreatePatronRequest {Id : & id , RequesterSymbol : & symbol }
1560+ // IllRequest is zero-valued, which parseAndValidateIllRequest rejects as errInvalidPatronRequest
1561+ jsonBytes , _ := json .Marshal (body )
1562+ req , _ := http .NewRequest ("PUT" , "/" , bytes .NewBuffer (jsonBytes ))
1563+ rr := httptest .NewRecorder ()
1564+ handler .PutPatronRequestsId (rr , req , "3" , proapi.PutPatronRequestsIdParams {})
1565+ assert .Equal (t , http .StatusBadRequest , rr .Code )
1566+ assert .Contains (t , rr .Body .String (), "illRequest must not be empty" )
1567+ }
1568+
1569+ func TestPutPatronRequestsIdInvalidBrokerSymbol (t * testing.T ) {
1570+ handler := NewPrApiHandler (new (PrRepoError ), mockEventBus , mockEventRepo , tenant .NewResolver (), nil , 10 )
1571+ handler .SetIllRepo (new (illRepoNoTx ))
1572+ previousBrokerSymbol := brokerSymbol
1573+ brokerSymbol = "BROKER"
1574+ defer func () {
1575+ brokerSymbol = previousBrokerSymbol
1576+ }()
1577+ req , _ := http .NewRequest ("PUT" , "/" , putBody (t , "3" , validIllRequest ()))
1578+ rr := httptest .NewRecorder ()
1579+ handler .PutPatronRequestsId (rr , req , "3" , proapi.PutPatronRequestsIdParams {})
1580+ assert .Equal (t , http .StatusInternalServerError , rr .Code )
1581+ assert .Contains (t , rr .Body .String (), "invalid BROKER_SYMBOL" )
1582+ }
0 commit comments