@@ -10,7 +10,7 @@ import (
1010)
1111
1212/*
13- GetNoteValidator
13+ GetNoteValidator
1414*/
1515func TestGetNoteValidator_Success (t * testing.T ) {
1616 req := httptest .NewRequest (http .MethodGet , "/notes/1" , nil )
@@ -30,7 +30,7 @@ func TestGetNoteValidator_InvalidMethod(t *testing.T) {
3030}
3131
3232/*
33- GetNotelistValidator
33+ GetNotelistValidator
3434*/
3535func TestGetNotelistValidator_Success (t * testing.T ) {
3636 req := httptest .NewRequest (http .MethodGet , "/notes" , nil )
@@ -49,7 +49,7 @@ func TestGetNotelistValidator_InvalidPath(t *testing.T) {
4949}
5050
5151/*
52- CreateNoteValidator
52+ CreateNoteValidator
5353*/
5454func TestCreateNoteValidator_Success (t * testing.T ) {
5555 req := httptest .NewRequest (http .MethodPost , "/notes" , nil )
@@ -68,7 +68,7 @@ func TestCreateNoteValidator_InvalidMethod(t *testing.T) {
6868}
6969
7070/*
71- DeleteNoteValidator
71+ DeleteNoteValidator
7272*/
7373func TestDeleteNoteValidator_Success (t * testing.T ) {
7474 req := httptest .NewRequest (http .MethodDelete , "/notes/2" , nil )
@@ -88,7 +88,7 @@ func TestDeleteNoteValidator_InvalidID(t *testing.T) {
8888}
8989
9090/*
91- UpdateNoteValidator
91+ UpdateNoteValidator
9292*/
9393func TestUpdateNoteValidator_Success (t * testing.T ) {
9494 body := strings .NewReader (`{"title":"test"}` )
@@ -101,6 +101,17 @@ func TestUpdateNoteValidator_Success(t *testing.T) {
101101 assert .Equal (t , 3 , id )
102102}
103103
104+ func TestUpdateNoteValidator_AcceptsContentTypeParameters (t * testing.T ) {
105+ body := strings .NewReader (`{"title":"test"}` )
106+ req := httptest .NewRequest (http .MethodPatch , "/notes/3" , body )
107+ req .Header .Set ("Content-Type" , "application/json; charset=utf-8" )
108+
109+ id , err := UpdateNoteValidator (req )
110+
111+ assert .Nil (t , err )
112+ assert .Equal (t , 3 , id )
113+ }
114+
104115func TestUpdateNoteValidator_InvalidContentType (t * testing.T ) {
105116 body := strings .NewReader (`{"title":"test"}` )
106117 req := httptest .NewRequest (http .MethodPatch , "/notes/3" , body )
@@ -110,3 +121,33 @@ func TestUpdateNoteValidator_InvalidContentType(t *testing.T) {
110121
111122 assert .NotNil (t , err )
112123}
124+
125+ func TestImportNotesValidator_Success (t * testing.T ) {
126+ body := strings .NewReader (`{"title":"test","content":{}}` )
127+ req := httptest .NewRequest (http .MethodPost , "/notes/imports" , body )
128+ req .Header .Set ("Content-Type" , "application/json" )
129+
130+ err := ImportNotesValidator (req )
131+
132+ assert .Nil (t , err )
133+ }
134+
135+ func TestImportNotesValidator_AcceptsContentTypeParameters (t * testing.T ) {
136+ body := strings .NewReader (`{"title":"test","content":{}}` )
137+ req := httptest .NewRequest (http .MethodPost , "/notes/imports" , body )
138+ req .Header .Set ("Content-Type" , "application/json; charset=utf-8" )
139+
140+ err := ImportNotesValidator (req )
141+
142+ assert .Nil (t , err )
143+ }
144+
145+ func TestImportNotesValidator_InvalidContentType (t * testing.T ) {
146+ body := strings .NewReader (`{"title":"test","content":{}}` )
147+ req := httptest .NewRequest (http .MethodPost , "/notes/imports" , body )
148+ req .Header .Set ("Content-Type" , "text/plain" )
149+
150+ err := ImportNotesValidator (req )
151+
152+ assert .NotNil (t , err )
153+ }
0 commit comments