Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,7 @@ func (service *PingdomTransactionMonitorService) addConfigToTransactionCheck(tra
if providerConfig.SendNotificationWhenDown > 0 {
transactionCheck.SendNotificationWhenDown = ptr.Int64(providerConfig.SendNotificationWhenDown)
}
if providerConfig.Paused {
transactionCheck.Active = ptr.Bool(!providerConfig.Paused)
}
transactionCheck.Active = ptr.Bool(!providerConfig.Paused)
if len(providerConfig.Tags) > 0 {
transactionCheck.Tags = providerConfig.Tags
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,36 @@ func TestGetSecretFromTemplate(t *testing.T) {
}
}

func TestAddConfigPausedActive(t *testing.T) {
tests := []struct {
name string
paused bool
expectedActive bool
}{
{name: "paused true -> inactive", paused: true, expectedActive: false},
{name: "paused false -> active", paused: false, expectedActive: true},
}

for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
service := PingdomTransactionMonitorService{}
transactionCheck := &pingdomNew.CheckWithoutID{}
monitor := models.Monitor{
Name: "test",
URL: "https://google.com",
Config: &endpointmonitorv1alpha1.PingdomTransactionConfig{
Paused: tc.paused,
},
}

service.addConfigToTransactionCheck(transactionCheck, monitor)

assert.Assert(t, transactionCheck.Active != nil, "Active must always be set")
assert.Equal(t, *transactionCheck.Active, tc.expectedActive)
})
}
}

func TestReplaceSecrets(t *testing.T) {
// Create a fake clientset
clientset := fake.NewSimpleClientset()
Expand Down
Loading