package test import ( "encoding/json" "fmt" "git.rtzhtech.cn/iss/public-lib/dto" "git.rtzhtech.cn/iss/public-lib/logic" "testing" ) func TestModifyAlarmStrategy(t *testing.T) { in := &dto.AddAlarmStrategyRes{} str := "{\n \"id\": 15,\n \"strategyid\": \"6965562430638268423\",\n \"strategyname\": \"测试123123\",\n \"alarmlevel\": 2,\n \"Relation\": [\n {\n \"id\": 18,\n \"strategyid\": \"6965562430638268423\",\n \"mpid\": \"6965498700256780289\",\n \"alarmtype\": 2,\n \"uplimit\": 321,\n \"dnlimit\": 321,\n \"dio\": 1,\n \"diffvalue\": 321,\n \"relation\": 3,\n \"create_at\": \"2022-08-17T14:58:16+08:00\",\n \"update_at\": \"0001-01-01T00:00:00Z\"\n },\n {\n \"id\": 17,\n \"strategyid\": \"6965562430638268423\",\n \"mpid\": \"6965500087841595394\",\n \"alarmtype\": 1,\n \"uplimit\": 312,\n \"dnlimit\": 321,\n \"dio\": 1,\n \"diffvalue\": 321,\n \"relation\": 1,\n \"create_at\": \"2022-08-17T14:58:16+08:00\",\n \"update_at\": \"0001-01-01T00:00:00Z\"\n }\n ]\n}" json.Unmarshal([]byte(str), in) l := logic.NewAlarmStrategyLogic() err := l.ModifyAlarmStrategy(in) if err != nil { t.Errorf("TestPage:%v\n", err) } } func TestGetAlarmStrategy(t *testing.T) { req := &dto.GetAlarmStrategyReq{} req.AppId = 1 l := logic.NewAlarmStrategyLogic() out, err := l.GetAlarmStrategy(req) if err != nil { t.Errorf("TestPage:%v\n", err) } fmt.Printf("total:%d\n", out.Total) for _, v := range out.List { fmt.Println(v) } }