|
- package main
-
- import "testing"
- import "log"
-
- func TestSaveLocation(t *testing.T) {
- tmpLead := createTempLead()
-
- info := crmdLocation{}
- info.Name = "name"
- info.LeadID = tmpLead.ID
- info.Longtitude = 10.77
- info.Latitude = 20.18
- info.Precision = 150
- location, err := info.Save()
- AssertEqual(t, err, nil, "")
- AssertEqual(t, location.Name, info.Name, "name mismatch ")
- AssertEqual(t, location.LeadID, info.LeadID, "lead mismatch")
- AssertEqual(t, location.Longtitude, info.Longtitude, "longtitude mismatch ")
- AssertEqual(t, location.Latitude, info.Latitude, "latitude mismatch ")
- AssertEqual(t, location.Precision, info.Precision, "precision mismatch ")
-
- //clean up
- crmDeleteEntity("Location", location.ID)
-
- AssertEqual(t, tmpLead.Delete(), true, "")
- }
-
- func createTempLead() (r crmdLead) {
- info := crmdLead{}
- info.FirstName = "testlocation"
- info.LastName = "canbedeleted"
- info.Password = "pass"
- info.Status = "Deletable"
- info.ForceDuplicate = true
- r, err := info.Save()
- if err != nil {
- log.Fatal(err)
- }
- return
- }
|