alarmStrategyLogic_test.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. package test
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "git.rtzhtech.cn/iss/public-lib/dto"
  6. "git.rtzhtech.cn/iss/public-lib/logic"
  7. "testing"
  8. )
  9. func TestModifyAlarmStrategy(t *testing.T) {
  10. in := &dto.AddAlarmStrategyRes{}
  11. 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}"
  12. json.Unmarshal([]byte(str), in)
  13. l := logic.NewAlarmStrategyLogic()
  14. err := l.ModifyAlarmStrategy(in)
  15. if err != nil {
  16. t.Errorf("TestPage:%v\n", err)
  17. }
  18. }
  19. func TestGetAlarmStrategy(t *testing.T) {
  20. req := &dto.GetAlarmStrategyReq{}
  21. req.AppId = 1
  22. l := logic.NewAlarmStrategyLogic()
  23. out, err := l.GetAlarmStrategy(req)
  24. if err != nil {
  25. t.Errorf("TestPage:%v\n", err)
  26. }
  27. fmt.Printf("total:%d\n", out.Total)
  28. for _, v := range out.List {
  29. fmt.Println(v)
  30. }
  31. }