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.

31 lines
663 B

  1. package weed_server
  2. import (
  3. "strings"
  4. "testing"
  5. )
  6. func TestParseURL(t *testing.T) {
  7. if vid, fid, _, _, _ := parseURLPath("/1,06dfa8a684"); true {
  8. if vid != "1" {
  9. t.Errorf("fail to parse vid: %s", vid)
  10. }
  11. if fid != "06dfa8a684" {
  12. t.Errorf("fail to parse fid: %s", fid)
  13. }
  14. }
  15. if vid, fid, _, _, _ := parseURLPath("/1,06dfa8a684_1"); true {
  16. if vid != "1" {
  17. t.Errorf("fail to parse vid: %s", vid)
  18. }
  19. if fid != "06dfa8a684_1" {
  20. t.Errorf("fail to parse fid: %s", fid)
  21. }
  22. if sepIndex := strings.LastIndex(fid, "_"); sepIndex > 0 {
  23. fid = fid[:sepIndex]
  24. }
  25. if fid != "06dfa8a684" {
  26. t.Errorf("fail to parse fid: %s", fid)
  27. }
  28. }
  29. }