Ejemplo n.º 1
0
func TestUserNameValid(t *testing.T) {
	t.Parallel()
	models.TxWrapper(func(tx *sql.Tx) {

		// 		a := assert.New(t)

		// 		res, c := get("")

		// 		// Stub params to eq username
		// 		GetParam = func(c *echo.Context, key string) string {
		// 			return "foobar"
		// 		}

		// 		UserNameValid(c)
		// 		a.Equal(200, res.Code)

		// 		u := CreateUser(tx, "foobar", "bar")
		// 		u.Create(tx)

		// 		res, c = get("")

		// 		UserNameValid(c)
		// 		a.Equal(406, res.Code)
	})
}
Ejemplo n.º 2
0
func TestSessionCreateInvalid(t *testing.T) {
	t.Parallel()
	models.TxWrapper(func(tx *sql.Tx) {
		// a := assert.New(t)

		// res, c := post(CreateSessionRequest("foo", "bar"))

		// SessionCreate(c)
		// a.Equal(http.StatusUnauthorized, res.Code)

		// // s := SessionError{}
		// // json.NewDecoder(res.Body).Decode(&s)
		// a.Equal("Invalid Credentials", res.Body)
	})
}
Ejemplo n.º 3
0
func TestUserGetValid(t *testing.T) {
	t.Parallel()
	models.TxWrapper(func(tx *sql.Tx) {
		// a := assert.New(t)

		// u := CreateUser(tx, "foo", "bar")

		// res, c := get("users/id")

		// GetParam = func(c *echo.Context, key string) string {
		// 	return u.ID
		// }

		// UserGet(c)

		// a.Equal(200, res.Code)
		// a.Equal(1, models.UserCount())

		// u = models.LoadUser(res.Body)

		// a.Equal("foo", u.Username)
	})
}