|
|
@@ -8,6 +8,7 @@ import (
|
|
|
"time"
|
|
|
|
|
|
"github.com/porter-dev/porter/internal/config"
|
|
|
+ "github.com/porter-dev/porter/internal/models"
|
|
|
"github.com/porter-dev/porter/internal/repository"
|
|
|
"github.com/porter-dev/porter/internal/repository/test"
|
|
|
"github.com/porter-dev/porter/server/api"
|
|
|
@@ -50,54 +51,60 @@ type userTest struct {
|
|
|
}
|
|
|
|
|
|
var createUserTests = []userTest{
|
|
|
+ // userTest{
|
|
|
+ // msg: "Create user",
|
|
|
+ // method: "POST",
|
|
|
+ // endpoint: "/api/users",
|
|
|
+ // body: `{
|
|
|
+ // "email": "belanger@getporter.dev",
|
|
|
+ // "password": "hello"
|
|
|
+ // }`,
|
|
|
+ // expStatus: http.StatusCreated,
|
|
|
+ // expBody: "",
|
|
|
+ // canQuery: true,
|
|
|
+ // },
|
|
|
+ // userTest{
|
|
|
+ // msg: "Create user invalid email",
|
|
|
+ // method: "POST",
|
|
|
+ // endpoint: "/api/users",
|
|
|
+ // body: `{
|
|
|
+ // "email": "notanemail",
|
|
|
+ // "password": "hello"
|
|
|
+ // }`,
|
|
|
+ // expStatus: http.StatusUnprocessableEntity,
|
|
|
+ // expBody: `{"code":1,"errors":["email validation failed"]}`,
|
|
|
+ // canQuery: true,
|
|
|
+ // },
|
|
|
+ // userTest{
|
|
|
+ // msg: "Create user missing field",
|
|
|
+ // method: "POST",
|
|
|
+ // endpoint: "/api/users",
|
|
|
+ // body: `{
|
|
|
+ // "password": "hello"
|
|
|
+ // }`,
|
|
|
+ // expStatus: http.StatusUnprocessableEntity,
|
|
|
+ // expBody: `{"code":1,"errors":["required validation failed"]}`,
|
|
|
+ // canQuery: true,
|
|
|
+ // },
|
|
|
+ // userTest{
|
|
|
+ // msg: "Create user cannot write to db",
|
|
|
+ // method: "POST",
|
|
|
+ // endpoint: "/api/users",
|
|
|
+ // body: `{
|
|
|
+ // "email": "belanger@getporter.dev",
|
|
|
+ // "password": "hello"
|
|
|
+ // }`,
|
|
|
+ // expStatus: http.StatusInternalServerError,
|
|
|
+ // expBody: `{"code":2,"errors":["data write error"]}`,
|
|
|
+ // canQuery: false,
|
|
|
+ // },
|
|
|
userTest{
|
|
|
- msg: "Create user",
|
|
|
- method: "POST",
|
|
|
- endpoint: "/api/users",
|
|
|
- body: `{
|
|
|
- "email": "belanger@getporter.dev",
|
|
|
- "password": "hello"
|
|
|
- }`,
|
|
|
- expStatus: http.StatusCreated,
|
|
|
- expBody: "",
|
|
|
- canQuery: true,
|
|
|
- },
|
|
|
- userTest{
|
|
|
- msg: "Create user invalid email",
|
|
|
- method: "POST",
|
|
|
- endpoint: "/api/users",
|
|
|
- body: `{
|
|
|
- "email": "notanemail",
|
|
|
- "password": "hello"
|
|
|
- }`,
|
|
|
- expStatus: http.StatusUnprocessableEntity,
|
|
|
- expBody: `{"code":1,"errors":["email validation failed"]}`,
|
|
|
- canQuery: true,
|
|
|
- },
|
|
|
- userTest{
|
|
|
- msg: "Create user missing field",
|
|
|
- method: "POST",
|
|
|
- endpoint: "/api/users",
|
|
|
- body: `{
|
|
|
- "password": "hello"
|
|
|
- }`,
|
|
|
- expStatus: http.StatusUnprocessableEntity,
|
|
|
- expBody: `{"code":1,"errors":["required validation failed"]}`,
|
|
|
- canQuery: true,
|
|
|
- },
|
|
|
- userTest{
|
|
|
- msg: "Create user cannot write to db",
|
|
|
- method: "POST",
|
|
|
- endpoint: "/api/users",
|
|
|
- body: `{
|
|
|
- "email": "belanger@getporter.dev",
|
|
|
- "password": "hello"
|
|
|
- }`,
|
|
|
- expStatus: http.StatusInternalServerError,
|
|
|
- expBody: `{"code":2,"errors":["data write error"]}`,
|
|
|
- canQuery: false,
|
|
|
- },
|
|
|
- userTest{
|
|
|
+ init: func(repo *repository.Repository) {
|
|
|
+ repo.User.CreateUser(&models.User{
|
|
|
+ Email: "belanger@getporter.dev",
|
|
|
+ Password: "hello",
|
|
|
+ })
|
|
|
+ },
|
|
|
msg: "Create user same email",
|
|
|
method: "POST",
|
|
|
endpoint: "/api/users",
|
|
|
@@ -105,7 +112,7 @@ var createUserTests = []userTest{
|
|
|
"email": "belanger@getporter.dev",
|
|
|
"password": "hello"
|
|
|
}`,
|
|
|
- expStatus: http.StatusCreated,
|
|
|
+ expStatus: http.StatusInternalServerError,
|
|
|
expBody: "",
|
|
|
canQuery: true,
|
|
|
},
|