test(app): signup process

master
Xeronith 2022-09-29 17:00:25 +03:30
rodzic 88eeb64438
commit 46db7166e6
2 zmienionych plików z 36 dodań i 0 usunięć

Wyświetl plik

@ -1,6 +1,7 @@
package tests
import (
"encoding/json"
"fmt"
"net/http"
"testing"
@ -24,6 +25,23 @@ func TestProfile(t *testing.T) {
t.FailNow()
}
result := &struct{ Code string }{}
if err := json.NewDecoder(resp.Body).Decode(result); err != nil {
t.Fatal(err)
}
resp, err = Post("/api/v1/verify", Payload{
"email": fmt.Sprintf("%s@%s", id, DOMAIN),
"code": result.Code,
})
if err != nil {
t.Fatal(err)
}
if resp.StatusCode != http.StatusOK {
t.FailNow()
}
resp, err = Get(fmt.Sprintf("/u/%s", id))
if err != nil {
t.Fatal(err)

Wyświetl plik

@ -1,6 +1,7 @@
package tests
import (
"encoding/json"
"fmt"
"net/http"
"testing"
@ -23,4 +24,21 @@ func TestSignup(t *testing.T) {
if resp.StatusCode != http.StatusOK {
t.FailNow()
}
result := &struct{ Code string }{}
if err := json.NewDecoder(resp.Body).Decode(result); err != nil {
t.Fatal(err)
}
resp, err = Post("/api/v1/verify", Payload{
"email": fmt.Sprintf("%s@%s", id, DOMAIN),
"code": result.Code,
})
if err != nil {
t.Fatal(err)
}
if resp.StatusCode != http.StatusOK {
t.FailNow()
}
}