func (this *TemplatesDetailController) LoadCustomTemplateDetail() {
	id, err := this.GetInt64("id", 0)
	template := entity.Template{}
	if err == nil {
		template.Id = id
		err = template.Load()
		if err == nil {
			this.Data["json"] = &template
			this.ServeJSON()
		}
	}
}
func (this *TemplatesDetailController) DeleteCustomTemplate() {
	id, err := this.GetInt64("id", 0)
	template := entity.Template{}
	if err == nil && id != 0 {
		template.Id = id
		err = template.Delete()
		if err != nil {
			this.Data["MessageErr"] = fmt.Sprintf("Errors: %s", err)
		}
	}
	if err != nil {
		this.Data["MessageErr"] = fmt.Sprintf("Errors: %s", err)
	}
}
func (this *TemplatesDetailController) Post() {
	action := this.GetString("action")
	sid, _ := this.GetInt64("sid", 0)
	switch action {
	case "":
		template := entity.Template{}
		template.Sid = sid
		template.Name = this.GetString("name")
		template.Description = this.GetString("description")
		template.FileType = this.GetString("fileType")
		template.TemplateFile = this.GetString("templatefile")
		template.TargetFile = this.GetString("targetfile")
		id, err := this.GetInt64("id", 0)
		if err == nil {
			if id == 0 {
				template.Save()
			} else {
				template.Id = id
				template.Update()
			}
		}

	case "delete":
		this.DeleteCustomTemplate()
	}
	redirectUrl := fmt.Sprintf("templatesdetail?serviceId=%d", sid)
	this.Redirect(redirectUrl, 301) //this.Get()
}
		errs = service1.Update()
		Expect(errs).ToNot(HaveOccurred())
		errs = service1.Load()
		Expect(errs).ToNot(HaveOccurred())

		Expect(service1.Name).To(Equal("New-mysql-service"))

		errs = service1.Delete()
		Expect(errs).ToNot(HaveOccurred())

	})
})

var _ = Describe("Testing Template CRUD", func() {
	It("Template Save", func() {
		var template entity.Template = entity.Template{Name: "template", Description: "description"}
		err := template.Save()
		Expect(err).ToNot(HaveOccurred())

		err = template.Delete()
		Expect(err).ToNot(HaveOccurred())
	})
	It("Template Update", func() {
		template := entity.Template{Name: "template mysql-service", Description: "provide mysql store service"}
		id, err := orm.NewOrm().Insert(&template)
		Expect(err).ToNot(HaveOccurred())
		template1 := entity.Template{}
		template1.Id = id
		errs := template1.Load()
		Expect(errs).ToNot(HaveOccurred())
		template1.Name = "New-template-mysql-service"