Skip to content

Commit

Permalink
add validate heartbeater base config tests
Browse files Browse the repository at this point in the history
  • Loading branch information
almostinf committed Nov 1, 2024
1 parent d6419d3 commit e9ef82c
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions notifier/selfstate/heartbeat/heartbeat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"
"time"

"github.com/moira-alert/moira"
logging "github.com/moira-alert/moira/logging/zerolog_adapter"
mock_clock "github.com/moira-alert/moira/mock/clock"
mock_moira_alert "github.com/moira-alert/moira/mock/moira-alert"
Expand Down Expand Up @@ -94,3 +95,41 @@ func TestNewHeartbeaterBase(t *testing.T) {
So(heartbeaterBase, ShouldResemble, expected)
})
}

func TestValidateHeartbeaterBaseConfig(t *testing.T) {
Convey("Test validation heartbeaterBaseConfig", t, func() {
Convey("With disabled config", func() {
hbCfg := HeartbeaterBaseConfig{}
err := moira.ValidateStruct(hbCfg)
So(err, ShouldBeNil)
})

Convey("With just enabled config", func() {
hbCfg := HeartbeaterBaseConfig{
Enabled: true,
}
err := moira.ValidateStruct(hbCfg)
So(err, ShouldNotBeNil)
})

Convey("With enabled config and added alert config", func() {
hbCfg := HeartbeaterBaseConfig{
Enabled: true,
AlertCfg: AlertConfig{},
}
err := moira.ValidateStruct(hbCfg)
So(err, ShouldNotBeNil)
})

Convey("With enabled config, added and filled alert config", func() {
hbCfg := HeartbeaterBaseConfig{
Enabled: true,
AlertCfg: AlertConfig{
Name: "test name",
},
}
err := moira.ValidateStruct(hbCfg)
So(err, ShouldBeNil)
})
})
}

0 comments on commit e9ef82c

Please sign in to comment.