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() }
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" errs = template1.Update() Expect(errs).ToNot(HaveOccurred()) errs = template1.Load() Expect(errs).ToNot(HaveOccurred()) Expect(template1.Name).To(Equal("New-template-mysql-service")) errs = template1.Delete() Expect(errs).ToNot(HaveOccurred()) }) }) var _ = Describe("Testing Component CRUD", func() { It("Component Save", func() { var component entity.Component = entity.Component{Name: "component", Value: "description"}