I have an endpoint /verification
which depends on a alphanumeric code(otp) sent on user's mobile. The code is generated and verified by third party via my api.
func TestVerification(t *testing.T) {
sendAlphaNumCode() //this sends code
req, err := http.NewRequest("POST", "/verification", bytes.NewBuffer([]byte(`{"code":"AXY98T"}`))) //code here is dynamic
//error handling
rr := httptest.NewRecorder()
handler := http.HandlerFunc(Verify)
handler.ServeHTTP(rr, req)
//assertions here
}
I am posting from mobile, so I could not copy paste the whole code
I can not take input from console as it's set to /dev/null
by golang while testing.
- Is there any way I can make golang tests wait for my input?
- Is mocking third party, the only way. If no, how else should I go about that?
I care about testing it in a functional way, if possible with third party api. preferably in golang. Every input is welcome.
I always accept answer Leave a comment for more clarity.
Aucun commentaire:
Enregistrer un commentaire