Пример #1
0
func (this *TemplatesController) DeleteCustomService() {
	id, err := this.GetInt64("id", 0)
	service := entity.Service{}
	if err == nil && id != 0 {
		service.Id = id
		err = service.Load()
		if err == nil {
			serviceDto := entity.ServiceDto{}
			serviceDto.Service = service
			serviceDto.Load()
			if serviceDto.Service.Where == utils.Deploy_On_PaaS {
				serviceDto.OnPaaS.Delete()
			}
			if serviceDto.Service.Where == utils.Deploy_On_Vms {
				serviceDto.OnCustom.Delete()
			}
		}

		err = service.Delete()
		if err != nil {
			this.Data["MessageErr"] = fmt.Sprintf("Errors: %s", err)
		}
	}
	if err != nil {
		this.Data["MessageErr"] = fmt.Sprintf("Errors: %s", err)
	}
}
import (
	"github.com/astaxie/beego/orm"
	"github.com/citycloud/citycloud.cf-deploy-ui/entity"
	_ "github.com/go-sql-driver/mysql"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Testing Service CRUD", func() {
	It("Service Save", func() {
		var service entity.Service = entity.Service{Name: "mysql-service", Description: "provide mysql store service"}
		err := service.Save()
		Expect(err).ToNot(HaveOccurred())

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