Skip to content

Commit

Permalink
refactor: skip tests if monitor config is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedwaleedmalik committed Aug 4, 2021
1 parent 524a419 commit 81170e9
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions pkg/monitors/uptime/uptime-monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ func TestGetAllMonitors(t *testing.T) {
service := UpTimeMonitorService{}
provider := util.GetProviderWithName(config, "Uptime")
if provider == nil {
panic("Failed to find provider")
log.Error(nil, "Failed to find provider")
return
}

// If test Config is passed skip the test
if provider.ApiKey == "API_KEY" {
return
Expand All @@ -37,9 +39,11 @@ func TestAddMonitorWithCorrectValues(t *testing.T) {

service := UpTimeMonitorService{}
provider := util.GetProviderWithName(config, "Uptime")
if nil == provider {
panic("Failed to find provider")
if provider == nil {
log.Error(nil, "Failed to find provider")
return
}

// If test Config is passed skip the test
if provider.ApiKey == "API_KEY" {
return
Expand Down Expand Up @@ -75,8 +79,10 @@ func TestUpdateMonitorWithCorrectValues(t *testing.T) {
service := UpTimeMonitorService{}
provider := util.GetProviderWithName(config, "Uptime")
if provider == nil {
panic("Failed to find provider")
log.Error(nil, "Failed to find provider")
return
}

// If test Config is passed skip the test
if provider.ApiKey == "API_KEY" {
return
Expand Down Expand Up @@ -143,8 +149,10 @@ func TestAddMonitorWithIncorrectValues(t *testing.T) {

provider := util.GetProviderWithName(config, "Uptime")
if provider == nil {
panic("Failed to find provider")
log.Error(nil, "Failed to find provider")
return
}

// If test Config is passed skip the test
if provider.ApiKey == "API_KEY" {
return
Expand Down Expand Up @@ -176,8 +184,10 @@ func TestEqualMonitor(t *testing.T) {

provider := util.GetProviderWithName(config, "Uptime")
if provider == nil {
panic("Failed to find provider")
log.Error(nil, "Failed to find provider")
return
}

// If test Config is passed skip the test
if provider.ApiKey == "API_KEY" {
return
Expand Down

0 comments on commit 81170e9

Please sign in to comment.