@@ -4,16 +4,17 @@ import (
44 "bytes"
55 "encoding/json"
66 "errors"
7+ "net/http"
8+ "net/http/httptest"
9+ "testing"
10+
711 "github.com/indexdata/crosslink/broker/common"
812 "github.com/indexdata/crosslink/broker/events"
913 pr_db "github.com/indexdata/crosslink/broker/patron_request/db"
1014 proapi "github.com/indexdata/crosslink/broker/patron_request/oapi"
1115 "github.com/jackc/pgx/v5"
1216 "github.com/stretchr/testify/assert"
1317 "github.com/stretchr/testify/mock"
14- "net/http"
15- "net/http/httptest"
16- "testing"
1718)
1819
1920var mockEventBus = new (MockEventBus )
@@ -51,7 +52,7 @@ func TestPostPatronRequests(t *testing.T) {
5152 assert .NoError (t , err , "failed to marshal patron request" )
5253 req , _ := http .NewRequest ("POST" , "/" , bytes .NewBuffer (jsonBytes ))
5354 rr := httptest .NewRecorder ()
54- handler .PostPatronRequests (rr , req )
55+ handler .PostPatronRequests (rr , req , proapi. PostPatronRequestsParams {} )
5556 if status := rr .Code ; status != http .StatusInternalServerError {
5657 t .Errorf ("handler returned wrong status code: got %v want %v" ,
5758 status , http .StatusInternalServerError )
@@ -62,7 +63,7 @@ func TestPostPatronRequestsInvalidJson(t *testing.T) {
6263 handler := NewApiHandler (new (PrRepoError ), mockEventBus )
6364 req , _ := http .NewRequest ("POST" , "/" , bytes .NewBuffer ([]byte ("a\" : v\" " )))
6465 rr := httptest .NewRecorder ()
65- handler .PostPatronRequests (rr , req )
66+ handler .PostPatronRequests (rr , req , proapi. PostPatronRequestsParams {} )
6667 if status := rr .Code ; status != http .StatusInternalServerError {
6768 t .Errorf ("handler returned wrong status code: got %v want %v" ,
6869 status , http .StatusInternalServerError )
@@ -73,7 +74,7 @@ func TestDeletePatronRequestsIdNotFound(t *testing.T) {
7374 handler := NewApiHandler (new (PrRepoError ), mockEventBus )
7475 req , _ := http .NewRequest ("POST" , "/" , nil )
7576 rr := httptest .NewRecorder ()
76- handler .DeletePatronRequestsId (rr , req , "2" )
77+ handler .DeletePatronRequestsId (rr , req , "2" , proapi. DeletePatronRequestsIdParams {} )
7778 if status := rr .Code ; status != http .StatusNotFound {
7879 t .Errorf ("handler returned wrong status code: got %v want %v" ,
7980 status , http .StatusNotFound )
@@ -84,7 +85,7 @@ func TestDeletePatronRequestsId(t *testing.T) {
8485 handler := NewApiHandler (new (PrRepoError ), mockEventBus )
8586 req , _ := http .NewRequest ("POST" , "/" , nil )
8687 rr := httptest .NewRecorder ()
87- handler .DeletePatronRequestsId (rr , req , "3" )
88+ handler .DeletePatronRequestsId (rr , req , "3" , proapi. DeletePatronRequestsIdParams {} )
8889 if status := rr .Code ; status != http .StatusInternalServerError {
8990 t .Errorf ("handler returned wrong status code: got %v want %v" ,
9091 status , http .StatusInternalServerError )
@@ -95,7 +96,7 @@ func TestGetPatronRequestsIdNotFound(t *testing.T) {
9596 handler := NewApiHandler (new (PrRepoError ), mockEventBus )
9697 req , _ := http .NewRequest ("POST" , "/" , nil )
9798 rr := httptest .NewRecorder ()
98- handler .GetPatronRequestsId (rr , req , "2" )
99+ handler .GetPatronRequestsId (rr , req , "2" , proapi. GetPatronRequestsIdParams {} )
99100 if status := rr .Code ; status != http .StatusNotFound {
100101 t .Errorf ("handler returned wrong status code: got %v want %v" ,
101102 status , http .StatusNotFound )
@@ -106,7 +107,7 @@ func TestGetPatronRequestsId(t *testing.T) {
106107 handler := NewApiHandler (new (PrRepoError ), mockEventBus )
107108 req , _ := http .NewRequest ("POST" , "/" , nil )
108109 rr := httptest .NewRecorder ()
109- handler .GetPatronRequestsId (rr , req , "1" )
110+ handler .GetPatronRequestsId (rr , req , "1" , proapi. GetPatronRequestsIdParams {} )
110111 if status := rr .Code ; status != http .StatusInternalServerError {
111112 t .Errorf ("handler returned wrong status code: got %v want %v" ,
112113 status , http .StatusInternalServerError )
@@ -120,7 +121,7 @@ func TestPutPatronRequestsIdNotFound(t *testing.T) {
120121 assert .NoError (t , err , "failed to marshal patron request" )
121122 req , _ := http .NewRequest ("POST" , "/" , bytes .NewBuffer (jsonBytes ))
122123 rr := httptest .NewRecorder ()
123- handler .PutPatronRequestsId (rr , req , "2" )
124+ handler .PutPatronRequestsId (rr , req , "2" , proapi. PutPatronRequestsIdParams {} )
124125 if status := rr .Code ; status != http .StatusNotFound {
125126 t .Errorf ("handler returned wrong status code: got %v want %v" ,
126127 status , http .StatusNotFound )
@@ -134,7 +135,7 @@ func TestPutPatronRequestsId(t *testing.T) {
134135 assert .NoError (t , err , "failed to marshal patron request" )
135136 req , _ := http .NewRequest ("POST" , "/" , bytes .NewBuffer (jsonBytes ))
136137 rr := httptest .NewRecorder ()
137- handler .PutPatronRequestsId (rr , req , "1" )
138+ handler .PutPatronRequestsId (rr , req , "1" , proapi. PutPatronRequestsIdParams {} )
138139 if status := rr .Code ; status != http .StatusInternalServerError {
139140 t .Errorf ("handler returned wrong status code: got %v want %v" ,
140141 status , http .StatusInternalServerError )
@@ -148,7 +149,7 @@ func TestPutPatronRequestsIdSaveError(t *testing.T) {
148149 assert .NoError (t , err , "failed to marshal patron request" )
149150 req , _ := http .NewRequest ("POST" , "/" , bytes .NewBuffer (jsonBytes ))
150151 rr := httptest .NewRecorder ()
151- handler .PutPatronRequestsId (rr , req , "3" )
152+ handler .PutPatronRequestsId (rr , req , "3" , proapi. PutPatronRequestsIdParams {} )
152153 if status := rr .Code ; status != http .StatusInternalServerError {
153154 t .Errorf ("handler returned wrong status code: got %v want %v" ,
154155 status , http .StatusInternalServerError )
@@ -159,7 +160,7 @@ func TestPutPatronRequestsIdInvalidJson(t *testing.T) {
159160 handler := NewApiHandler (new (PrRepoError ), mockEventBus )
160161 req , _ := http .NewRequest ("POST" , "/" , bytes .NewBuffer ([]byte ("a\" :v\" " )))
161162 rr := httptest .NewRecorder ()
162- handler .PutPatronRequestsId (rr , req , "3" )
163+ handler .PutPatronRequestsId (rr , req , "3" , proapi. PutPatronRequestsIdParams {} )
163164 if status := rr .Code ; status != http .StatusInternalServerError {
164165 t .Errorf ("handler returned wrong status code: got %v want %v" ,
165166 status , http .StatusInternalServerError )
0 commit comments