func (this *ServiceComponentController) DeleteComponent() { id, err := this.GetInt64("id", 0) component := entity.Component{} if err == nil && id != 0 { component.Id = id err = component.Delete() if err != nil { this.Data["MessageErr"] = fmt.Sprintf("Errors: %s", err) } } if err != nil { this.Data["MessageErr"] = fmt.Sprintf("Errors: %s", err) } }
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"} err := component.Save() Expect(err).ToNot(HaveOccurred()) err = component.Delete() Expect(err).ToNot(HaveOccurred()) }) It("Component Update", func() { component := entity.Component{Name: "component mysql-service", Value: "provide mysql store service"} id, err := orm.NewOrm().Insert(&component) Expect(err).ToNot(HaveOccurred()) component1 := entity.Component{} component1.Id = id errs := component1.Load() Expect(errs).ToNot(HaveOccurred()) component1.Name = "New-template-mysql-service" errs = component1.Update() Expect(errs).ToNot(HaveOccurred()) errs = component1.Load() Expect(errs).ToNot(HaveOccurred())