package tests

import (
	"net/http"
	"net/url"
	"wechat-conf/controllers"
	"testing"

	. "github.com/smartystreets/goconvey/convey"
)

func TestGetCmsCaseList(t *testing.T) {

	Convey("获取案场列表", t, func() {
		Convey("正常业务", func() {
			params := url.Values{}
			params.Add("orgid", "1")

			result := &controllers.JSONMessage{}

			code, _, err := NewRequestMock().Request(http.MethodGet, "/api/guest/MQ/cms/case", params, result)

			// http 常规判断, 可以省略
			So(code, ShouldEqual, http.StatusOK)
			So(err, ShouldBeNil)

			// 业务返回判断
			So(result.Code, ShouldEqual, http.StatusOK)
			So(result.Result, ShouldNotBeEmpty)
		})

		Convey("机构不传报错", func() {
			result := &controllers.JSONMessage{}

			code, _, err := NewRequestMock().Request(http.MethodGet, "/api/guest/MQ/cms/case", nil, result)

			// http 常规判断, 可以省略
			So(code, ShouldEqual, http.StatusOK)
			So(err, ShouldBeNil)

			// 业务返回判断
			So(result.Code, ShouldNotEqual, http.StatusOK)
		})

	})
}