123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447 |
- package service
- import (
- "context"
- "go-common/app/admin/ep/melloi/model"
- "testing"
- "github.com/smartystreets/goconvey/convey"
- )
- func TestServiceQueryDraft(t *testing.T) {
- convey.Convey("QueryDraft", t, func(convCtx convey.C) {
- var (
- scene = &model.Scene{
- UserName: "chenmeng",
- }
- )
- convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
- p1, err := s.QueryDraft(scene)
- convCtx.Convey("Then err should be nil.p1 should not be nil.", func(convCtx convey.C) {
- convCtx.So(err, convey.ShouldBeNil)
- convCtx.So(p1, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestServiceUpdateScene(t *testing.T) {
- convey.Convey("UpdateScene", t, func(convCtx convey.C) {
- var (
- scene = &model.Scene{
- ID: 66,
- }
- )
- convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
- fusing, err := s.UpdateScene(scene)
- convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
- convCtx.So(err, convey.ShouldBeNil)
- convCtx.So(fusing, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestServiceAddScene(t *testing.T) {
- convey.Convey("AddScene", t, func(convCtx convey.C) {
- var (
- scene = &model.Scene{
- SceneName: "CMTest001",
- UserName: "chenmeng",
- Department: "test",
- Project: "ep",
- APP: "melloi",
- IsDraft: 1,
- }
- )
- convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
- id, err := s.AddScene(scene)
- convCtx.Convey("Then err should be nil.id should not be nil.", func(convCtx convey.C) {
- convCtx.So(err, convey.ShouldBeNil)
- convCtx.So(id, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestServiceQueryAPI(t *testing.T) {
- convey.Convey("QueryAPI", t, func(convCtx convey.C) {
- var (
- scene = &model.Scene{
- ID: 325,
- SceneType: 1,
- }
- )
- convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
- p1, err := s.QueryAPI(scene)
- convCtx.Convey("Then err should be nil.p1 should not be nil.", func(convCtx convey.C) {
- convCtx.So(err, convey.ShouldBeNil)
- convCtx.So(p1, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestServiceAddConfig(t *testing.T) {
- convey.Convey("AddConfig", t, func(convCtx convey.C) {
- var (
- script = &model.Script{
- ThreadsSum: 120,
- LoadTime: 300,
- ReadyTime: 10,
- SceneID: 325,
- GroupID: 1,
- }
- )
- convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
- err := s.AddConfig(script)
- convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
- convCtx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestServiceQueryTree(t *testing.T) {
- convey.Convey("QueryTree", t, func(convCtx convey.C) {
- var (
- script = &model.Script{
- SceneID: 325,
- }
- )
- convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
- p1, err := s.QueryTree(script)
- convCtx.Convey("Then err should be nil.p1 should not be nil.", func(convCtx convey.C) {
- convCtx.So(err, convey.ShouldBeNil)
- convCtx.So(p1, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestServiceQueryScenesByPage(t *testing.T) {
- convey.Convey("QueryScenesByPage", t, func(convCtx convey.C) {
- var (
- c = context.Background()
- sessionID = ""
- scene = &model.Scene{
- Department: "test",
- Project: "ep",
- APP: "melloi",
- SceneName: "场景压测cmtest01",
- UserName: "chenmeng",
- }
- page = &model.Pagination{
- PageNum: int32(1),
- PageSize: int32(20),
- }
- qsrq = &model.QuerySceneRequest{
- Scene: *scene,
- Pagination: *page,
- Executor: "chenmeng",
- }
- )
- convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
- rsp, err := s.QueryScenesByPage(c, sessionID, qsrq)
- convCtx.Convey("Then err should be nil.rsp should not be nil.", func(convCtx convey.C) {
- convCtx.So(err, convey.ShouldBeNil)
- convCtx.So(rsp, convey.ShouldNotBeNil)
- })
- })
- })
- }
- //func TestServiceAddAndExecuScene(t *testing.T) {
- // convey.Convey("AddAndExecuScene", t, func(convCtx convey.C) {
- // var (
- // c = context.Background()
- // scene model.Scene
- // )
- // convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
- // resp, err := s.AddAndExecuScene(c, scene)
- // convCtx.Convey("Then err should be nil.resp should not be nil.", func(convCtx convey.C) {
- // convCtx.So(err, convey.ShouldBeNil)
- // convCtx.So(resp, convey.ShouldNotBeNil)
- // })
- // })
- // })
- //}
- func TestServiceSaveScene(t *testing.T) {
- convey.Convey("SaveScene", t, func(convCtx convey.C) {
- var (
- scene = &model.Scene{
- ID: 66,
- IsDraft: 0,
- SceneType: 2,
- }
- )
- convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
- err := s.SaveScene(scene)
- convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
- convCtx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestServiceSaveOrder(t *testing.T) {
- convey.Convey("SaveOrder", t, func(convCtx convey.C) {
- var (
- reqList = []*model.GroupOrder{
- {
- GroupID: 1,
- RunOrder: 2,
- ID: 980,
- TestName: "cm-test",
- },
- {
- GroupID: 1,
- RunOrder: 1,
- ID: 973,
- TestName: "status111",
- },
- }
- req = model.SaveOrderReq{
- GroupOrderList: reqList,
- }
- scene = &model.Scene{
- SceneType: 1,
- }
- )
- convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
- err := s.SaveOrder(req, scene)
- convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
- convCtx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestServiceQueryRelation(t *testing.T) {
- convey.Convey("QueryRelation", t, func(convCtx convey.C) {
- var (
- script = &model.Script{
- ID: 1568,
- }
- )
- convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
- p1, err := s.QueryRelation(script)
- convCtx.Convey("Then err should be nil.p1 should not be nil.", func(convCtx convey.C) {
- convCtx.So(err, convey.ShouldBeNil)
- convCtx.So(p1, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestServiceDeleteAPI(t *testing.T) {
- convey.Convey("DeleteAPI", t, func(convCtx convey.C) {
- var (
- script = &model.Script{
- ID: 1568,
- }
- )
- convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
- err := s.DeleteAPI(script)
- convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
- convCtx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- //func TestServiceDoScenePtest(t *testing.T) {
- // convey.Convey("DoScenePtest", t, func(convCtx convey.C) {
- // var (
- // c = context.Background()
- // ptestScene model.DoPtestSceneParam
- // addPtest bool
- // )
- // convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
- // resp, err := s.DoScenePtest(c, ptestScene, addPtest)
- // convCtx.Convey("Then err should be nil.resp should not be nil.", func(convCtx convey.C) {
- // convCtx.So(err, convey.ShouldBeNil)
- // convCtx.So(resp, convey.ShouldNotBeNil)
- // })
- // })
- // })
- //}
- func TestServiceDoScenePtestBatch(t *testing.T) {
- convey.Convey("DoScenePtestBatch", t, func(convCtx convey.C) {
- var (
- c = context.Background()
- ptestScenes model.DoPtestSceneParams
- )
- convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
- err := s.DoScenePtestBatch(c, ptestScenes, "")
- convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
- convCtx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- //func TestServiceGetSceneInfo(t *testing.T) {
- // convey.Convey("GetSceneInfo", t, func(convCtx convey.C) {
- // var (
- // scene = &model.Scene{}
- // )
- // convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
- // sceneInfo := GetSceneInfo(scene)
- // convCtx.Convey("Then sceneInfo should not be nil.", func(convCtx convey.C) {
- // convCtx.So(sceneInfo, convey.ShouldNotBeNil)
- // })
- // })
- // })
- //}
- func TestServiceQueryExistAPI(t *testing.T) {
- convey.Convey("QueryExistAPI", t, func(convCtx convey.C) {
- var (
- c = context.Background()
- sessionID = "24133ff6e561c0cdd0bfb1a8e7802f1c"
- script = &model.Script{
- SceneID: 325,
- }
- page = &model.Pagination{
- PageNum: int32(1),
- PageSize: int32(10),
- }
- req = &model.APIInfoRequest{
- Script: *script,
- Pagination: *page,
- }
- )
- convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
- res, err := s.QueryExistAPI(c, sessionID, req)
- convCtx.Convey("Then err should be nil.res should not be nil.", func(convCtx convey.C) {
- convCtx.So(err, convey.ShouldBeNil)
- convCtx.So(res, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestServiceQueryPreview(t *testing.T) {
- convey.Convey("QueryPreview", t, func(convCtx convey.C) {
- var (
- req = &model.Script{
- SceneID: 325,
- GroupID: 1,
- }
- )
- convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
- preRes, err := s.QueryPreview(req)
- convCtx.Convey("Then err should be nil.preRes should not be nil.", func(convCtx convey.C) {
- convCtx.So(err, convey.ShouldBeNil)
- convCtx.So(preRes, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestServiceQueryParams(t *testing.T) {
- convey.Convey("QueryParams", t, func(convCtx convey.C) {
- var (
- req = &model.Script{
- SceneID: 325,
- }
- )
- convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
- res, tempRes, err := s.QueryParams(req)
- convCtx.Convey("Then err should be nil.res,tempRes should not be nil.", func(convCtx convey.C) {
- convCtx.So(err, convey.ShouldBeNil)
- convCtx.So(tempRes, convey.ShouldNotBeNil)
- convCtx.So(res, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestServiceUpdateBindScene(t *testing.T) {
- convey.Convey("UpdateBindScene", t, func(convCtx convey.C) {
- var (
- bindScene = &model.BindScene{
- SceneID: 325,
- ID: "2000",
- }
- )
- convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
- err := s.UpdateBindScene(bindScene)
- convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
- convCtx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestServiceQueryDrawRelation(t *testing.T) {
- convey.Convey("QueryDrawRelation", t, func(convCtx convey.C) {
- var (
- scene = &model.Scene{
- ID: 980,
- }
- )
- convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
- res, tempRes, err := s.QueryDrawRelation(scene)
- convCtx.Convey("Then err should be nil.res,tempRes should not be nil.", func(convCtx convey.C) {
- convCtx.So(err, convey.ShouldBeNil)
- convCtx.So(tempRes, convey.ShouldNotBeNil)
- convCtx.So(res, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestServiceDeleteDraft(t *testing.T) {
- convey.Convey("DeleteDraft", t, func(convCtx convey.C) {
- var (
- scene = &model.Scene{
- UserName: "chenmeng",
- ID: 980,
- }
- )
- convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
- err := s.DeleteDraft(scene)
- convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
- convCtx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestServiceQueryConfig(t *testing.T) {
- convey.Convey("QueryConfig", t, func(convCtx convey.C) {
- var (
- script = &model.Script{
- SceneID: 325,
- GroupID: 1,
- }
- )
- convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
- p1, err := s.QueryConfig(script)
- convCtx.Convey("Then err should be nil.p1 should not be nil.", func(convCtx convey.C) {
- convCtx.So(err, convey.ShouldBeNil)
- convCtx.So(p1, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestServiceDeleteScene(t *testing.T) {
- convey.Convey("DeleteScene", t, func(convCtx convey.C) {
- var (
- scene = &model.Scene{
- ID: 325,
- }
- )
- convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
- err := s.DeleteScene(scene)
- convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
- convCtx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
|