kopia lustrzana https://github.com/reiver/greatape
test(app): ✅ signup process
rodzic
88eeb64438
commit
46db7166e6
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue