You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
466 B

  1. package operation
  2. import (
  3. "fmt"
  4. "testing"
  5. "time"
  6. )
  7. func TestCaching(t *testing.T) {
  8. var (
  9. vc VidCache
  10. )
  11. var locations []Location
  12. locations = append(locations, Location{Url: "a.com:8080"})
  13. vc.Set("123", locations, time.Second)
  14. ret, _ := vc.Get("123")
  15. if ret == nil {
  16. t.Fatal("Not found vid 123")
  17. }
  18. fmt.Printf("vid 123 locations = %v\n", ret)
  19. time.Sleep(2 * time.Second)
  20. ret, _ = vc.Get("123")
  21. if ret != nil {
  22. t.Fatal("Not found vid 123")
  23. }
  24. }