@@ -108,9 +108,38 @@ func (s *CreateDocumentSuite) TestCreateMultipartDocument() {
108
108
require .Equal (s .T (), expectedResponse .Payload , body .Payload )
109
109
}
110
110
111
- func (s * CreateDocumentSuite ) TestStaticCreateDocument () {}
111
+ func (s * CreateDocumentSuite ) TestStaticCreateDocument () {
112
+ // Setup multipart/form-data body
113
+ var b bytes.Buffer
114
+ mw := multipart .NewWriter (& b )
115
+ mw .WriteField ("content" , "test" )
116
+ mw .Close ()
117
+
118
+ // Send request
119
+ req , _ := http .NewRequest (http .MethodPost , "/" , & b )
120
+ req .Header .Add ("Content-Type" , mw .FormDataContentType ())
121
+ rr := executeRequest (req , s .srv )
122
+
123
+ // Assertions
124
+ require .Equal (s .T (), http .StatusMovedPermanently , rr .Result ().StatusCode )
125
+ require .Equal (s .T (), "/12345678" , rr .Result ().Header .Get ("Location" ))
126
+ // add a test for content-type and body?
127
+ }
128
+
129
+ func (s * CreateDocumentSuite ) TestCreateBadDocument () {
130
+ req , _ := http .NewRequest (http .MethodPost , "/api/" ,
131
+ bytes .NewReader ([]byte (`{"content": "1"}` )),
132
+ )
133
+ req .Header .Set ("Content-Type" , "application/json" )
134
+ rr := executeRequest (req , s .srv )
112
135
113
- func (s * CreateDocumentSuite ) TestCreateBadDocument () {}
136
+ x , _ := io .ReadAll (rr .Result ().Body )
137
+ var body DocumentResponse
138
+ json .Unmarshal (x , & body )
139
+
140
+ require .Equal (s .T (), http .StatusBadRequest , rr .Result ().StatusCode )
141
+ require .Equal (s .T (), "Content: the length must be between 2 and 400000." , body .Error )
142
+ }
114
143
115
144
func TestCreateDocumentSuite (t * testing.T ) {
116
145
suite .Run (t , new (CreateDocumentSuite ))
0 commit comments