kopia lustrzana https://github.com/reiver/greatape
test(app): ♻️ isolate and refine tests
rodzic
ae3abf5723
commit
0ea6d410fe
|
@ -17,6 +17,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type Payload map[string]interface{}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DOMAIN = "domain.social"
|
DOMAIN = "domain.social"
|
||||||
ROOT = "http://localhost"
|
ROOT = "http://localhost"
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package tests
|
package tests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"app/models/types"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -11,12 +10,11 @@ import (
|
||||||
|
|
||||||
func TestLogin(t *testing.T) {
|
func TestLogin(t *testing.T) {
|
||||||
id := uuid.New().String()
|
id := uuid.New().String()
|
||||||
payload := types.LoginDTO{
|
|
||||||
Email: fmt.Sprintf("%s@%s", id, DOMAIN),
|
|
||||||
Password: "123456",
|
|
||||||
}
|
|
||||||
|
|
||||||
resp, err := Post("/api/v1/login", payload)
|
resp, err := Post("/api/v1/login", Payload{
|
||||||
|
"email": fmt.Sprintf("%s@%s", id, DOMAIN),
|
||||||
|
"password": "123456",
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package tests
|
package tests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"app/models/types"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -11,15 +10,12 @@ import (
|
||||||
|
|
||||||
func TestSignup(t *testing.T) {
|
func TestSignup(t *testing.T) {
|
||||||
id := uuid.New().String()
|
id := uuid.New().String()
|
||||||
payload := types.SignupDTO{
|
|
||||||
LoginDTO: types.LoginDTO{
|
|
||||||
Email: fmt.Sprintf("%s@%s", id, DOMAIN),
|
|
||||||
Password: "123456",
|
|
||||||
},
|
|
||||||
Username: id,
|
|
||||||
}
|
|
||||||
|
|
||||||
resp, err := Post("/api/v1/signup", payload)
|
resp, err := Post("/api/v1/signup", Payload{
|
||||||
|
"email": fmt.Sprintf("%s@%s", id, DOMAIN),
|
||||||
|
"password": "123456",
|
||||||
|
"username": id,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue