示例#1
0
func TestAppGuides(t *testing.T) {
	MockedDTX := &apicontext.DataContext{}
	var err error
	if MockedDTX, err = apicontextmock.Mock(); err != nil {
		return
	}
	Convey("Test Create AppGuide", t, func() {
		var err error
		var ag ApplicationGuide

		//create
		ag.FileType = "pdf"
		ag.Url = "test.com"
		ag.Website.ID = MockedDTX.WebsiteID
		err = ag.Create(MockedDTX)
		So(err, ShouldBeNil)

		//get
		err = ag.Get(MockedDTX)
		So(err, ShouldBeNil)

		//get by site
		ags, err := ag.GetBySite(MockedDTX)

		So(err, ShouldBeNil)
		So(len(ags), ShouldBeGreaterThanOrEqualTo, 1)

		//delete
		err = ag.Delete()
		So(err, ShouldBeNil)

	})
	_ = apicontextmock.DeMock(MockedDTX)
}
示例#2
0
func TestBadCrudStmts(t *testing.T) {
	MockedDTX, err := apicontextmock.Mock()
	if err != nil {
		return
	}
	Convey("Testing bad statements", t, func() {
		var l CustomerLocation
		l.Name = "test"
		l.Address = "testA"
		l.City = "Tes"
		l.State.Id = 12
		l.IsPrimary = true
		createLocation = "Bad Query Stmt"
		updateLocation = "Bad Query Stmt"
		deleteLocation = "Bad Query Stmt"
		Convey("Testing Bad Create()", func() {
			err := l.Create(MockedDTX)
			So(err, ShouldNotBeNil)
		})

		Convey("Testing Bad Update()", func() {
			l.Name = "test2"
			err := l.Update(MockedDTX)
			So(err, ShouldNotBeNil)
		})
		Convey("Testing Bad Delete()", func() {
			err := l.Delete(MockedDTX)
			So(err, ShouldNotBeNil)
		})

	})
	_ = apicontextmock.DeMock(MockedDTX)
}
示例#3
0
func TestGetMakes(t *testing.T) {
	var l Lookup
	l.Brands = append(l.Brands, 1)

	MockedDTX, err := apicontextmock.Mock()
	if err != nil {
		return
	}
	Convey("Testing GetMakes() without year", t, func() {
		err := l.GetMakes(MockedDTX)
		So(err, ShouldEqual, nil)
		So(l.Makes, ShouldNotEqual, nil)
		So(len(l.Makes), ShouldEqual, 0)
	})

	Convey("Testing GetMakes() with bogus year", t, func() {
		l.Vehicle.Base.Year = 1
		err := l.GetMakes(MockedDTX)
		So(err, ShouldEqual, nil)
		So(l.Makes, ShouldNotEqual, nil)
		So(len(l.Makes), ShouldEqual, 0)
		So(l.Vehicle.Base.Year, ShouldEqual, 1)
	})

	Convey("Testing GetMakes() with year", t, func() {
		l.Vehicle.Base.Year = 2010
		err := l.GetMakes(MockedDTX)
		So(err, ShouldEqual, nil)
		So(l.Makes, ShouldNotEqual, nil)
		So(l.Makes, ShouldHaveSameTypeAs, []string{})
		So(l.Vehicle.Base.Year, ShouldEqual, 2010)
	})
	_ = apicontextmock.DeMock(MockedDTX)
}
示例#4
0
func TestVinLookup(t *testing.T) {
	dtx, err := apicontextmock.Mock()
	if err != nil {
		t.Log(err)
	}

	Convey("Testing VinPartLookup", t, func() {
		vs, err := VinPartLookup(buickVin, dtx)
		if err != sql.ErrNoRows {
			So(err, ShouldBeNil)
			So(len(vs.Parts), ShouldBeGreaterThanOrEqualTo, 1)

		}
		if err != sql.ErrNoRows {
			vs, err = VinPartLookup(taurusVin, dtx)
			So(err, ShouldBeNil)
			So(len(vs.Parts), ShouldBeGreaterThanOrEqualTo, 1)

			//Make sure it's a Taurus - VINs should be constant
			So(vs.Vehicle.Base.Model, ShouldEqual, "Taurus")

			//We have 2010 Taurus Hitches
			So(len(vs.Parts), ShouldBeGreaterThanOrEqualTo, 1)
		}

	})
	_ = apicontextmock.DeMock(dtx)
}
示例#5
0
func TestCustomerLocations(t *testing.T) {
	var l CustomerLocation
	var err error

	MockedDTX, err := apicontextmock.Mock()
	if err != nil {
		return
	}
	Convey("Testing Locations", t, func() {

		Convey("Testing Create", func() {
			l.Name = "test"
			l.Address = "testA"
			l.City = "Tes"
			l.State.Id = 12
			l.IsPrimary = true
			l.Email = "Tes"
			l.Fax = "Tes"
			l.Phone = "Tes"
			l.Coordinates.Latitude = 44.913687
			l.Coordinates.Longitude = -91.89981
			l.CustomerId = MockedDTX.CustomerID
			l.ContactPerson = "Tes"
			l.IsPrimary = true
			l.PostalCode = "Tes"
			l.ShippingDefault = false
			err := l.Create(MockedDTX)
			So(err, ShouldBeNil)
		})

		Convey("Update", func() {
			l.Name = "Chuck Norris"
			err := l.Update(MockedDTX)
			So(err, ShouldBeNil)
			So(l.Name, ShouldNotEqual, "test")

		})

		Convey("Testing GetAll()", func() {
			locations, err := GetAllLocations(MockedDTX)
			So(len(locations), ShouldBeGreaterThanOrEqualTo, 0)
			So(err, ShouldBeNil)
		})
		Convey("Get", func() {
			err = l.Get()
			So(err, ShouldBeNil)
			So(l, ShouldNotBeNil)
		})

		Convey("Delete", func() {
			err := l.Delete(MockedDTX)
			So(err, ShouldBeNil)

		})

	})
	_ = apicontextmock.DeMock(MockedDTX)
}
示例#6
0
func TestGetFaqs(t *testing.T) {
	var f Faq
	var err error

	MockedDTX, err := apicontextmock.Mock()
	if err != nil {
		return
	}

	f.Question = "testQuestion"
	f.Answer = "testAnswer"

	Convey("Testing Create", t, func() {
		err = f.Create(MockedDTX)
		So(err, ShouldBeNil)
		So(f, ShouldNotBeNil)
		So(f.Question, ShouldEqual, "testQuestion")
		So(f.Answer, ShouldEqual, "testAnswer")
	})
	Convey("Testing Update", t, func() {
		f.Question = "testQuestion222"
		f.Answer = "testAnswer222"
		err = f.Update(MockedDTX)
		So(err, ShouldBeNil)
		So(f, ShouldNotBeNil)
		So(f.Question, ShouldEqual, "testQuestion222")
		So(f.Answer, ShouldEqual, "testAnswer222")
	})
	Convey("Testing Get", t, func() {
		err = f.Get(MockedDTX)
		So(err, ShouldBeNil)
		So(f, ShouldNotBeNil)
		So(f.Question, ShouldHaveSameTypeAs, "str")
		So(f.Answer, ShouldHaveSameTypeAs, "str")

		var fs Faqs
		fs, err = GetAll(MockedDTX)
		So(fs, ShouldNotBeNil)
		So(err, ShouldBeNil)
		So(len(fs), ShouldNotBeNil)

		as, err := Search(MockedDTX, f.Question, "", "1", "0")
		So(as, ShouldNotBeNil)
		So(err, ShouldBeNil)
		So(as.Pagination.Page, ShouldEqual, 1)
		So(as.Pagination.ReturnedCount, ShouldNotBeNil)
		So(as.Pagination.PerPage, ShouldNotBeNil)
		So(as.Pagination.PerPage, ShouldEqual, len(as.Objects))
	})
	Convey("Testing Delete", t, func() {
		err = f.Delete()
		So(err, ShouldBeNil)

	})

	_ = apicontextmock.DeMock(MockedDTX)
}
示例#7
0
func BenchmarkSearch(b *testing.B) {
	MockedDTX, err := apicontextmock.Mock()
	if err != nil {
		return
	}
	for i := 0; i < b.N; i++ {
		Search("Title", "", "", "", "", "", "", "1", "1", MockedDTX)
	}
	_ = apicontextmock.DeMock(MockedDTX)
}
示例#8
0
func BenchmarkGetLeads(b *testing.B) {
	MockedDTX, err := apicontextmock.Mock()
	if err != nil {
		return
	}
	for i := 0; i < b.N; i++ {
		GetLeads("1", "1", MockedDTX)
	}
	_ = apicontextmock.DeMock(MockedDTX)
}
示例#9
0
func BenchmarkGetAllTestimonials(b *testing.B) {
	MockedDTX, err := apicontextmock.Mock()
	if err != nil {
		return
	}
	for i := 0; i < b.N; i++ {
		GetAllTestimonials(0, 1, false, MockedDTX)
	}
	_ = apicontextmock.DeMock(MockedDTX)
}
示例#10
0
func BenchmarkGetAllContacts(b *testing.B) {
	MockedDTX, err := apicontextmock.Mock()
	if err != nil {
		return
	}
	for i := 0; i < b.N; i++ {
		GetAllContacts(1, 1, MockedDTX)
	}
	_ = apicontextmock.DeMock(MockedDTX)
}
示例#11
0
func BenchmarkGetAllTechSupport(b *testing.B) {
	MockedDTX, err := apicontextmock.Mock()
	if err != nil {
		return
	}
	for i := 0; i < b.N; i++ {
		GetAllTechSupport(MockedDTX)
	}
	_ = apicontextmock.DeMock(MockedDTX)
}
示例#12
0
文件: faq_test.go 项目: ninnemana/API
func TestFaqs(t *testing.T) {
	var f faq_model.Faq
	var err error
	dtx, err := apicontextmock.Mock()
	if err != nil {
		t.Log(err)
	}
	Convey("Test Faqs", t, func() {
		//test create
		form := url.Values{"question": {"test"}, "answer": {"testAnswer"}}
		v := form.Encode()
		body := strings.NewReader(v)
		testThatHttp.Request("post", "/faqs", "", "", Create, body, "application/x-www-form-urlencoded")
		So(testThatHttp.Response.Code, ShouldEqual, 200)
		err = json.Unmarshal(testThatHttp.Response.Body.Bytes(), &f)
		So(f, ShouldHaveSameTypeAs, faq_model.Faq{})

		//test update
		form = url.Values{"question": {"test new"}, "answer": {"testAnswer new"}}
		v = form.Encode()
		body = strings.NewReader(v)
		testThatHttp.RequestWithDtx("put", "/faqs/", ":id", strconv.Itoa(f.ID), Update, body, "application/x-www-form-urlencoded", dtx)
		So(testThatHttp.Response.Code, ShouldEqual, 200)
		err = json.Unmarshal(testThatHttp.Response.Body.Bytes(), &f)
		So(f, ShouldHaveSameTypeAs, faq_model.Faq{})

		//test get
		testThatHttp.RequestWithDtx("get", "/faqs/", ":id", strconv.Itoa(f.ID), Get, nil, "application/x-www-form-urlencoded", dtx)
		So(testThatHttp.Response.Code, ShouldEqual, 200)
		err = json.Unmarshal(testThatHttp.Response.Body.Bytes(), &f)
		So(f, ShouldHaveSameTypeAs, faq_model.Faq{})
		So(f.Question, ShouldEqual, "test new")

		//test getall
		testThatHttp.Request("get", "/faqs", "", "", GetAll, nil, "application/x-www-form-urlencoded")
		So(testThatHttp.Response.Code, ShouldEqual, 200)
		var fs faq_model.Faqs
		err = json.Unmarshal(testThatHttp.Response.Body.Bytes(), &fs)
		So(len(fs), ShouldBeGreaterThanOrEqualTo, 0)

		//test search - responds w/ horrid pagination object
		testThatHttp.Request("get", "/faqs/search", "", "?question=test new", Search, nil, "application/x-www-form-urlencoded")
		So(testThatHttp.Response.Code, ShouldEqual, 200)
		var l pagination.Objects
		err = json.Unmarshal(testThatHttp.Response.Body.Bytes(), &l)
		So(len(l.Objects), ShouldBeGreaterThanOrEqualTo, 0)

		//test delete
		testThatHttp.Request("delete", "/faqs/", ":id", strconv.Itoa(f.ID), Delete, nil, "application/x-www-form-urlencoded")
		So(testThatHttp.Response.Code, ShouldEqual, 200)
		err = json.Unmarshal(testThatHttp.Response.Body.Bytes(), &f)
		So(f, ShouldHaveSameTypeAs, faq_model.Faq{})
	})
	_ = apicontextmock.DeMock(dtx)
}
示例#13
0
func TestTestimonials(t *testing.T) {
	MockedDTX, err := apicontextmock.Mock()
	if err != nil {
		return
	}
	var test Testimonial
	test.BrandID = MockedDTX.BrandID
	Convey("Testing Create Testimonial", t, func() {
		test.Content = "Test Content"
		err = test.Create()
		So(err, ShouldBeNil)
	})
	Convey("Update", t, func() {
		test.Content = "New Content"
		test.Active = true
		test.Approved = true
		err = test.Update()
		So(err, ShouldBeNil)

	})

	Convey("Get testimonial", t, func() {
		err = test.Get(MockedDTX)
		So(err, ShouldBeNil)
	})
	Convey("GetAll - No paging", t, func() {
		ts, err := GetAllTestimonials(0, 1, false, MockedDTX)
		So(err, ShouldBeNil)
		So(len(ts), ShouldBeGreaterThan, 0)

	})

	Convey("GetAll - Paged", t, func() {
		ts, err := GetAllTestimonials(0, 1, false, MockedDTX)

		So(err, ShouldBeNil)
		So(len(ts), ShouldBeGreaterThan, 0)

	})

	Convey("GetAll - randomized", t, func() {
		ts, err := GetAllTestimonials(0, 1, true, MockedDTX)
		So(err, ShouldBeNil)
		So(len(ts), ShouldBeGreaterThan, 0)

	})
	Convey("Delete", t, func() {
		err = test.Delete()
		So(err, ShouldBeNil)

	})

	_ = apicontextmock.DeMock(MockedDTX)
}
示例#14
0
func BenchmarkGetAllBlogCategories(b *testing.B) {
	MockedDTX := &apicontext.DataContext{}
	var err error
	if MockedDTX, err = apicontextmock.Mock(); err != nil {
		return
	}
	for i := 0; i < b.N; i++ {
		GetAllCategories(MockedDTX)
	}
	_ = apicontextmock.DeMock(MockedDTX)
}
示例#15
0
func TestPart(t *testing.T) {
	MockedDTX, err := apicontextmock.Mock()
	if err != nil {
		return
	}
	Convey("Testing Basics", t, func() {
		p := Part{
			ID: 11000,
		}
		err := p.FromDatabase([]int{1, 3})
		So(err, ShouldBeNil)
	})

	Convey("Testing All", t, func() {
		parts, err := All(0, 1, MockedDTX)
		So(err, ShouldBeNil)
		So(len(parts), ShouldEqual, 1)
		So(parts, ShouldHaveSameTypeAs, []Part{})
	})

	Convey("Testing GetLatest", t, func() {
		parts, err := Latest(10, MockedDTX)
		So(err, ShouldBeNil)
		So(len(parts), ShouldEqual, 10)
		So(parts, ShouldHaveSameTypeAs, []Part{})
		So(parts[0].DateAdded.String(), ShouldBeGreaterThan, parts[8].DateAdded.String())
	})

	Convey("Testing Featured", t, func() {
		parts, err := Featured(3, MockedDTX)
		So(err, ShouldBeNil)
		So(len(parts), ShouldEqual, 3)
		So(parts, ShouldHaveSameTypeAs, []Part{})
	})

	Convey("Testing Related", t, func() {
		p := Part{
			ID: 11000,
		}
		p.Get(MockedDTX)
		parts, err := p.GetRelated(MockedDTX)
		So(err, ShouldBeNil)
		So(parts, ShouldHaveSameTypeAs, []Part{})
	})

	Convey("Get BY Old Part Number", t, func() {
		p := Part{
			OldPartNumber: "BM01821501",
		}
		err = p.GetPartByOldPartNumber()
		So(err, ShouldBeNil)
	})
	_ = apicontextmock.DeMock(MockedDTX)
}
示例#16
0
func BenchmarkGetAllFaq(b *testing.B) {
	MockedDTX, err := apicontextmock.Mock()
	if err != nil {
		return
	}
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		GetAll(MockedDTX)
	}
	b.StopTimer()
	_ = apicontextmock.DeMock(MockedDTX)
}
示例#17
0
func TestTechSupport(te *testing.T) {

	dtx, err := apicontextmock.Mock()
	if err != nil {
		te.Log(err)
	}

	Convey("TechSupport", te, func() {
		var t techSupport.TechSupport
		var ts []techSupport.TechSupport

		qs := make(url.Values, 0)
		qs.Add("key", dtx.APIKey)

		t.Contact.LastName = "test contact"
		t.Contact.FirstName = "test contact first"
		t.Contact.Email = "*****@*****.**"
		t.Contact.Type = "test"
		t.Contact.Subject = "test"
		t.Contact.Message = "test"
		t.Contact.Brand.ID = dtx.BrandID
		t.BrandID = dtx.BrandID

		err = t.Contact.Add(dtx)
		So(err, ShouldBeNil)

		response := httprunner.ParameterizedJsonRequest("POST", "/techSupport/:contactReceiverTypeID/:sendEmail", "/techSupport/1/false", &qs, t, CreateTechSupport)
		So(response.Code, ShouldEqual, 200)
		So(json.Unmarshal(response.Body.Bytes(), &t), ShouldEqual, nil)

		response = httprunner.ParameterizedRequest("GET", "/techSupport/:id", "/techSupport/"+strconv.Itoa(t.ID), &qs, nil, GetTechSupport)
		So(response.Code, ShouldEqual, 200)
		So(json.Unmarshal(response.Body.Bytes(), &t), ShouldEqual, nil)

		response = httprunner.ParameterizedRequest("GET", "/techSupport/contact/:id", "/techSupport/contact/"+strconv.Itoa(t.Contact.ID), &qs, nil, GetTechSupportByContact)
		te.Log(response.Body)
		So(response.Code, ShouldEqual, 200)
		So(json.Unmarshal(response.Body.Bytes(), &ts), ShouldEqual, nil)

		response = httprunner.ParameterizedRequest("GET", "/techSupport", "/techSupport", &qs, nil, GetAllTechSupport)
		So(response.Code, ShouldEqual, 200)
		So(json.Unmarshal(response.Body.Bytes(), &ts), ShouldEqual, nil)

		response = httprunner.ParameterizedRequest("DELETE", "/techSupport/:id", "/techSupport/"+strconv.Itoa(t.ID), &qs, nil, DeleteTechSupport)
		So(response.Code, ShouldEqual, 200)
		So(json.Unmarshal(response.Body.Bytes(), &t), ShouldEqual, nil)

		err = t.Contact.Delete()
		So(err, ShouldBeNil)

	})
	_ = apicontextmock.DeMock(dtx)
}
示例#18
0
func TestNews(t *testing.T) {
	var n News
	var err error
	n.Title = "test news"

	MockedDTX, err := apicontextmock.Mock()
	if err != nil {
		return
	}

	Convey("Test Create", t, func() {
		err = n.Create(MockedDTX)
		So(err, ShouldBeNil)
	})
	Convey("Test Update", t, func() {
		n.Title = "Different Title"
		err = n.Update(MockedDTX)
		So(err, ShouldBeNil)
	})
	Convey("Test Get", t, func() {
		err = n.Get(MockedDTX)
		So(err, ShouldBeNil)
		So(n.Title, ShouldEqual, "Different Title")

		obj, err := Search(n.Title, "", "", "", "", "", "", "1", "1", MockedDTX)
		So(len(obj.Objects), ShouldEqual, 1)
		So(err, ShouldBeNil)

		ns, err := GetAll(MockedDTX)
		if err != sql.ErrNoRows {
			So(err, ShouldBeNil)
			So(len(ns), ShouldBeGreaterThan, 0)
		}
		ts, err := GetTitles("1", "1", MockedDTX)
		if err != sql.ErrNoRows {
			So(err, ShouldBeNil)
			So(len(ts.Objects), ShouldBeGreaterThan, 0)
		}
		ls, err := GetLeads("1", "1", MockedDTX)
		if err != sql.ErrNoRows {
			So(err, ShouldBeNil)
			So(len(ls.Objects), ShouldBeGreaterThan, 0)
		}

	})
	Convey("Test Delete", t, func() {
		err = n.Delete(MockedDTX)
		So(err, ShouldBeNil)
	})
	_ = apicontextmock.DeMock(MockedDTX)

}
示例#19
0
func BenchmarkDeleteContact(b *testing.B) {
	MockedDTX, err := apicontextmock.Mock()
	if err != nil {
		return
	}
	c := setupDummyContact()
	c.Add(MockedDTX)
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		c.Delete()
	}
	_ = apicontextmock.DeMock(MockedDTX)
}
示例#20
0
func TestWarranties(t *testing.T) {
	MockedDTX, err := apicontextmock.Mock()
	if err != nil {
		return
	}
	Convey("Testing CRUD", t, func() {
		var w Warranty
		var err error
		w.PartNumber = 123456
		date := time.Now()
		w.Date = &date
		//make contact
		w.Contact.Email = "[email protected]"
		w.Contact.LastName = "l"
		w.Contact.FirstName = "f"
		w.Contact.Type = "t"
		w.Contact.Subject = "s"
		w.Contact.Message = "m"

		err = w.Create()
		So(err, ShouldBeNil)

		err = w.Get()
		So(err, ShouldBeNil)

		wts, err := w.GetByContact()
		So(err, ShouldBeNil)
		So(len(wts), ShouldBeGreaterThan, 0)

		ws, err := GetAllWarranties(MockedDTX)
		if err != sql.ErrNoRows {
			So(err, ShouldBeNil)
			So(len(ws), ShouldBeGreaterThan, 0)
		}

		Convey("DELETE", func() {
			err = w.Delete()
			So(err, ShouldBeNil)
			Convey("Cleanup", func() {
				//cleanup contact
				if w.Contact.ID > 0 {
					err = w.Contact.Delete()
					So(err, ShouldBeNil)

				}
			})
		})

	})
	_ = apicontextmock.DeMock(MockedDTX)
}
示例#21
0
func TestGetLifestyles(t *testing.T) {
	var l Lifestyle
	MockedDTX, err := apicontextmock.Mock()
	if err != nil {
		return
	}

	Convey("Testing CRUD", t, func() {

		l.Name = "testName"
		l.LongDesc = "Long description"
		err := l.Create(MockedDTX)
		So(err, ShouldBeNil)
		err = l.Get(MockedDTX)
		So(err, ShouldBeNil)
		So(l, ShouldNotBeNil)
		So(l.Name, ShouldEqual, "testName")
		So(l.LongDesc, ShouldEqual, "Long description")

		//Update
		l.Name = "newName"
		l.Image = "image"
		l.ShortDesc = "Desc"
		err = l.Update(MockedDTX)
		So(err, ShouldBeNil)
		err = l.Get(MockedDTX)

		So(err, ShouldBeNil)
		So(l, ShouldNotBeNil)
		So(l.Name, ShouldEqual, "newName")
		So(l.Image, ShouldEqual, "image")
		So(l.ShortDesc, ShouldEqual, "Desc")

		//Gets
		ls, err := GetAll(MockedDTX)
		So(err, ShouldBeNil)
		So(ls, ShouldHaveSameTypeAs, Lifestyles{})

		err = l.Get(MockedDTX)
		So(err, ShouldBeNil)
		So(l, ShouldNotBeNil)
		So(l.Name, ShouldHaveSameTypeAs, "str")
		So(l.ShortDesc, ShouldHaveSameTypeAs, "str")

		//Delete
		err = l.Delete()
		So(err, ShouldBeNil)

	})
	_ = apicontextmock.DeMock(MockedDTX)
}
示例#22
0
func TestBrands(t *testing.T) {
	var err error
	b := setupDummyBrand()
	dtx, err := apicontextmock.Mock()
	if err != nil {
		return
	}

	Convey("Testing GetAll", t, func() {
		brands, err := GetAllBrands()
		So(err, ShouldBeNil)
		So(len(brands), ShouldBeGreaterThanOrEqualTo, 0)
	})

	Convey("Testing Brands - CRUD", t, func() {
		Convey("Testing Create", func() {
			err = b.Create()
			So(err, ShouldBeNil)
			So(b.ID, ShouldNotEqual, 0)

			err = b.Get()
			So(err, ShouldBeNil)
			So(b.ID, ShouldBeGreaterThan, 0)
			So(b.Name, ShouldEqual, "TESTER")

			b.Name = "TESTING"
			err = b.Update()
			So(err, ShouldBeNil)
			So(b.Name, ShouldEqual, "TESTING")

			sites, err := getWebsites(b.ID)
			So(err, ShouldBeNil)
			So(sites, ShouldHaveSameTypeAs, []Website{})

			brands, err := GetUserBrands(dtx.CustomerID)
			So(err, ShouldBeNil)
			So(brands, ShouldHaveSameTypeAs, []Brand{})

			err = b.Delete()
			So(err, ShouldBeNil)

		})
		Convey("Testing Get - Bad ID", func() {
			br := Brand{}
			err = br.Get()
			So(err, ShouldNotBeNil)
		})
	})
	apicontextmock.DeMock(dtx)

}
示例#23
0
func BenchmarkCreateLifestyle(b *testing.B) {
	ls := setupDummyLifestyle()
	MockedDTX, err := apicontextmock.Mock()
	if err != nil {
		return
	}
	for i := 0; i < b.N; i++ {
		ls.Create(MockedDTX)
		b.StopTimer()
		ls.Delete()
		b.StartTimer()
	}
	_ = apicontextmock.DeMock(MockedDTX)
}
示例#24
0
func BenchmarkCreateTestimonial(b *testing.B) {
	MockedDTX, err := apicontextmock.Mock()
	if err != nil {
		return
	}
	test := setupDummyTestimonial()
	for i := 0; i < b.N; i++ {
		b.StartTimer()
		test.Create()
		b.StopTimer()
		test.Delete()
	}
	_ = apicontextmock.DeMock(MockedDTX)
}
示例#25
0
func BenchmarkCreateNews(b *testing.B) {
	MockedDTX, err := apicontextmock.Mock()
	if err != nil {
		return
	}
	n := setupDummyNews()
	for i := 0; i < b.N; i++ {
		n.Create(MockedDTX)
		b.StopTimer()
		n.Delete(MockedDTX)
		b.StartTimer()
	}
	_ = apicontextmock.DeMock(MockedDTX)
}
示例#26
0
func BenchmarkCreateFaq(b *testing.B) {
	MockedDTX, err := apicontextmock.Mock()
	if err != nil {
		return
	}
	f := setupDummyFaq()
	for i := 0; i < b.N; i++ {
		f.Create(MockedDTX)
		b.StopTimer()
		f.Delete()
		b.StartTimer()
	}
	_ = apicontextmock.DeMock(MockedDTX)
}
示例#27
0
func TestTechSupport(t *testing.T) {
	var err error
	var tc TechSupport
	tc.Issue = "This is an issue"
	//make contact
	tc.Contact.Email = "[email protected]"
	tc.Contact.LastName = "techSupport"
	tc.Contact.FirstName = "f"
	tc.Contact.Subject = "s"
	tc.Contact.Message = "m"

	MockedDTX, err := apicontextmock.Mock()
	if err != nil {
		return
	}

	Convey("Test Create TechSupport", t, func() {

		err = tc.Create()
		So(err, ShouldBeNil)
	})
	Convey("Test Get TechSupport", t, func() {

		err = tc.Get()
		So(err, ShouldBeNil)
	})
	Convey("Test Get TechSupport By Contact", t, func() {

		ts, err := tc.GetByContact(MockedDTX)
		So(err, ShouldBeNil)
		So(len(ts), ShouldBeGreaterThanOrEqualTo, 0)
	})
	Convey("Test Get All TechSupport", t, func() {

		allTs, err := GetAllTechSupport(MockedDTX)
		So(err, ShouldBeNil)
		So(len(allTs), ShouldBeGreaterThanOrEqualTo, 0)
	})
	Convey("Test Delete TechSupport", t, func() {

		err = tc.Delete()
		So(err, ShouldBeNil)

		err = tc.Contact.Delete()
		So(err, ShouldBeNil)
	})
	_ = apicontextmock.DeMock(MockedDTX)

}
示例#28
0
func BenchmarkDeleteBlog(b *testing.B) {
	MockedDTX := &apicontext.DataContext{}
	var err error
	if MockedDTX, err = apicontextmock.Mock(); err != nil {
		return
	}
	blog := setupDummyBlog()
	for i := 0; i < b.N; i++ {
		b.StopTimer()
		blog.Create(MockedDTX)
		b.StartTimer()
		blog.Delete(MockedDTX)
	}
	_ = apicontextmock.DeMock(MockedDTX)
}
示例#29
0
func TestBusiness(t *testing.T) {
	var err error
	MockedDTX := &apicontext.DataContext{}
	if MockedDTX, err = apicontextmock.Mock(); err != nil {
		return
	}
	Convey("Testing Gets", t, func() {
		Convey("Testing GetAllBusinessClasses()", func() {
			classes, err := GetAllBusinessClasses(MockedDTX)
			So(len(classes), ShouldBeGreaterThanOrEqualTo, 0)
			So(err, ShouldBeNil)
		})
	})
	_ = apicontextmock.DeMock(MockedDTX)
}
示例#30
0
func BenchmarkGetLifestyle(b *testing.B) {
	MockedDTX, err := apicontextmock.Mock()
	if err != nil {
		return
	}
	ls := setupDummyLifestyle()
	ls.Create(MockedDTX)
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		ls.Get(MockedDTX)
	}
	b.StopTimer()
	ls.Delete()
	_ = apicontextmock.DeMock(MockedDTX)
}