@@ -19,7 +19,6 @@ package emailpassword
1919import (
2020 "bytes"
2121 "encoding/json"
22- "fmt"
2322 "io"
2423 "net/http"
2524 "net/http/httptest"
@@ -104,7 +103,7 @@ func TestInvalidAPIInputForFormFields(t *testing.T) {
104103 }{
105104 {
106105 input : map [string ]interface {}{},
107- expected : "Missing input param" ,
106+ expected : "Missing input param: formFields " ,
108107 fieldError : false ,
109108 },
110109 {
@@ -221,8 +220,6 @@ func TestInvalidAPIInputForFormFields(t *testing.T) {
221220 resp , err := http .Post (testServer .URL + api , "application/json" , bytes .NewBuffer (objToJson (testCase .input )))
222221 assert .NoError (t , err )
223222
224- fmt .Println (testCase , api , resp .StatusCode )
225-
226223 if testCase .fieldError {
227224 assert .Equal (t , 200 , resp .StatusCode )
228225 } else {
@@ -239,16 +236,16 @@ func TestInvalidAPIInputForFormFields(t *testing.T) {
239236 t .Error (err .Error ())
240237 }
241238
242- // if testCase.fieldError {
243- // assert.Equal(t, "FIELD_ERROR", data["status"].(string))
239+ if testCase .fieldError {
240+ assert .Equal (t , "FIELD_ERROR" , data ["status" ].(string ))
244241
245- // for _, formField := range data["formFields"].([]interface{}) {
246- // errorMessage := formField.(map[string]interface{})["error"]
247- // assert.Equal(t, testCase.expected, errorMessage)
248- // }
249- // } else {
250- // assert.Equal(t, testCase.expected, data["message"])
251- // }
242+ for _ , formField := range data ["formFields" ].([]interface {}) {
243+ errorMessage := formField .(map [string ]interface {})["error" ]
244+ assert .Equal (t , testCase .expected , errorMessage )
245+ }
246+ } else {
247+ assert .Equal (t , testCase .expected , data ["message" ])
248+ }
252249
253250 }
254251 }
0 commit comments