You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.3 KiB
56 lines
1.3 KiB
package service |
|
|
|
import ( |
|
"context" |
|
"testing" |
|
|
|
"go-common/app/admin/main/apm/model/monitor" |
|
"go-common/library/log" |
|
|
|
"github.com/smartystreets/goconvey/convey" |
|
) |
|
|
|
func TestService_AddMonitor(t *testing.T) { |
|
var ( |
|
c = context.Background() |
|
err error |
|
) |
|
convey.Convey("Test AddMonitor", t, func(ctx convey.C) { |
|
err = svr.AddMonitor(c) |
|
ctx.So(err, convey.ShouldBeNil) |
|
}) |
|
} |
|
|
|
func TestService_PrometheusList(t *testing.T) { |
|
var ( |
|
c = context.Background() |
|
) |
|
convey.Convey("Test PrometheusList", t, func(ctx convey.C) { |
|
ret, err := svr.PrometheusList(c, "main.account.member-service", "xx", "count") |
|
ctx.So(ret, convey.ShouldNotBeEmpty) |
|
ctx.So(err, convey.ShouldBeNil) |
|
}) |
|
} |
|
|
|
func TestService_BroadCastList(t *testing.T) { |
|
var ( |
|
c = context.Background() |
|
) |
|
convey.Convey("Test BroadCastList", t, func(ctx convey.C) { |
|
ret, err := svr.BroadCastList(c) |
|
ctx.So(ret, convey.ShouldNotBeEmpty) |
|
ctx.So(err, convey.ShouldBeNil) |
|
}) |
|
} |
|
|
|
func TestService_Times(t *testing.T) { |
|
mt := &monitor.Monitor{} |
|
if err := svr.DB.Where("app_id = ?", "main.app-svr.app-feed-http").First(mt).Error; err != nil { |
|
log.Error("s.Prometheus query first error(%v)", err) |
|
return |
|
} |
|
convey.Convey("Test Times", t, func(ctx convey.C) { |
|
ret := svr.times(mt.MTime) |
|
t.Logf("times=%v", ret) |
|
}) |
|
}
|
|
|