delCache_test.go 820 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package http
  2. import (
  3. "context"
  4. "fmt"
  5. . "github.com/smartystreets/goconvey/convey"
  6. "go-common/library/ecode"
  7. "net/url"
  8. "testing"
  9. )
  10. type DelCacheRes struct {
  11. Code int `json:"code"`
  12. }
  13. func queryDelCache(t *testing.T, uid int64) *DelCacheRes {
  14. params := url.Values{}
  15. params.Set("uid", fmt.Sprintf("%d", uid))
  16. req, _ := client.NewRequest("GET", _delCacheURL, "127.0.0.1", params)
  17. var res DelCacheRes
  18. err := client.Do(context.TODO(), req, &res)
  19. if err != nil {
  20. t.Errorf("client.Do() error(%v)", err)
  21. t.FailNow()
  22. }
  23. return &res
  24. }
  25. func TestDelCache(t *testing.T) {
  26. once.Do(startHTTP)
  27. Convey("Del Cache", t, func() {
  28. var uid int64 = 1
  29. queryGet(t, uid, "pc")
  30. r := queryDelCache(t, uid)
  31. So(r.Code, ShouldEqual, 0)
  32. r = queryDelCache(t, uid)
  33. So(r.Code, ShouldEqual, ecode.NothingFound)
  34. })
  35. }