api_user_test.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package main
  2. import (
  3. "github.com/gogf/gf/net/ghttp"
  4. "testing"
  5. )
  6. func TestUserGet(t *testing.T) {
  7. if r, e := ghttp.Get(TestURL + "/system/user/get?id=1"); e != nil {
  8. t.Error(e)
  9. } else {
  10. t.Log(string(r.ReadAll()))
  11. r.Close()
  12. }
  13. }
  14. func TestUserInsert(t *testing.T) {
  15. if r, e := ghttp.Get(TestURL + "/system/user/access?name=john&age=18"); e != nil {
  16. t.Error(e)
  17. } else {
  18. t.Log(string(r.ReadAll()))
  19. r.Close()
  20. }
  21. }
  22. func TestUserUpdate(t *testing.T) {
  23. if r, e := ghttp.Get(TestURL + "/system/user/cache"); e != nil {
  24. t.Error(e)
  25. } else {
  26. t.Log(string(r.ReadAll()))
  27. r.Close()
  28. }
  29. }
  30. func TestUserDelete(t *testing.T) {
  31. if r, e := ghttp.Post(TestURL+"/system/user/access", "name=john&age=18"); e != nil {
  32. t.Error(e)
  33. } else {
  34. t.Log(string(r.ReadAll()))
  35. r.Close()
  36. }
  37. }
  38. func TestUserList(t *testing.T) {
  39. if r, e := ghttp.Get(TestURL + "/system/user/mysql"); e != nil {
  40. t.Error(e)
  41. } else {
  42. t.Log(string(r.ReadAll()))
  43. r.Close()
  44. }
  45. }
  46. func TestUserPage(t *testing.T) {
  47. if r, e := ghttp.Get(TestURL + "/system/user/mysql"); e != nil {
  48. t.Error(e)
  49. } else {
  50. t.Log(string(r.ReadAll()))
  51. r.Close()
  52. }
  53. }