您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

location_test.go 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package main
  2. import "testing"
  3. import "log"
  4. func TestSaveLocation(t *testing.T) {
  5. tmpLead := createTempLead()
  6. info := crmdLocation{}
  7. info.Name = "name"
  8. info.LeadID = tmpLead.ID
  9. info.Longtitude = 10.77
  10. info.Latitude = 20.18
  11. info.Precision = 150
  12. location, err := info.Save()
  13. AssertEqual(t, err, nil, "")
  14. AssertEqual(t, location.Name, info.Name, "name mismatch ")
  15. AssertEqual(t, location.LeadID, info.LeadID, "lead mismatch")
  16. AssertEqual(t, location.Longtitude, info.Longtitude, "longtitude mismatch ")
  17. AssertEqual(t, location.Latitude, info.Latitude, "latitude mismatch ")
  18. AssertEqual(t, location.Precision, info.Precision, "precision mismatch ")
  19. //clean up
  20. crmDeleteEntity("Location", location.ID)
  21. AssertEqual(t, tmpLead.Delete(), true, "")
  22. }
  23. func createTempLead() (r crmdLead) {
  24. info := crmdLead{}
  25. info.FirstName = "testlocation"
  26. info.LastName = "canbedeleted"
  27. info.Password = "pass"
  28. info.Status = "Deletable"
  29. info.ForceDuplicate = true
  30. r, err := info.Save()
  31. if err != nil {
  32. log.Fatal(err)
  33. }
  34. return
  35. }