set_online_test.go 1.7 KB
package product_plan

import (
	"github.com/go-pg/pg/v10"
	"net/http"

	"github.com/gavv/httpexpect"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	pG "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/infrastructure/pg"
)

var _ = Describe("计划上线", func() {
	var productPlanId int64
	BeforeEach(func() {
		_, err := pG.DB.QueryOne(
			pg.Scan(&productPlanId),
			"INSERT INTO product_plans (product_plan_id, company_id, org_id, batch_number, product_date, workshop, work_on, machine, plan_product_name, plan_devoted, plan_status, work_station, remark, created_at, updated_at, deleted_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING product_plan_id",
			"testProductPlanId", "testCompanyId", "testOrgId", "testBatchNumber", "testProductDate", "testWorkshop", "testWorkOn", "testMachine", "testPlanProductName", "testPlanDevoted", "testPlanStatus", "testWorkStation", "testRemark", "testCreatedAt", "testUpdatedAt", "testDeletedAt")
		Expect(err).NotTo(HaveOccurred())
	})
	Describe("计划上线", func() {
		Context("", func() {
			It("", func() {
				httpExpect := httpexpect.New(GinkgoT(), server.URL)
				body := map[string]interface{}{
					"productPlanId": "int",
					"workshopId":    "int",
					"lineId":        "int",
					"sectionId":     "int",
				}
				httpExpect.POST("/product-plans/set-online").
					WithJSON(body).
					Expect().
					Status(http.StatusOK).
					JSON().
					Object().
					ContainsKey("code").ValueEqual("code", 0).
					ContainsKey("msg").ValueEqual("msg", "ok").
					ContainsKey("data").Value("data").Object()
			})
		})
	})
	AfterEach(func() {
		_, err := pG.DB.Exec("DELETE FROM product_plans WHERE true")
		Expect(err).NotTo(HaveOccurred())
	})
})