func TestUserCreateValid(t *testing.T) { t.Parallel() db.TxWrapper(func(tx *sql.Tx) { a := assert.New(t) u := &models.User{ Username: "******", Password: "******", Email: "*****@*****.**", FirstName: "Foo", LastName: "Bar", } res, c := post(lib.ToJSON(u)) users.Create(c) a.Equal(201, res.Code) u = models.LoadUser(res.Body) a.Equal("foo", u.Username) a.Equal("Foo", u.FirstName) a.Equal("Bar", u.LastName) a.NotEmpty(u.ID) }) }
func TestToJSON(t *testing.T) { t.Parallel() a := assert.New(t) x := &Foobar{1, 3} a.Equal(`{"a":1,"c":3}`, strings.TrimSpace(lib.ToJSON(x))) }