Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

42 lines
1.0KB

  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. }