Run go fix
This commit is contained in:
@@ -22,7 +22,6 @@ func TestAlertValidate(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
@@ -77,7 +76,6 @@ func TestAlertSend(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
@@ -123,7 +121,6 @@ func TestAlertBuildTemplate(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
+2
-4
@@ -24,7 +24,6 @@ func TestLoadConfig(t *testing.T) {
|
||||
{"./test/valid-config.hcl", nil, "Valid config file"},
|
||||
}
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
@@ -51,7 +50,7 @@ func TestDefaultConfig(t *testing.T) {
|
||||
m.Config{
|
||||
CheckInterval: 1 * time.Second,
|
||||
DefaultAlertAfter: 2,
|
||||
DefaultAlertEvery: Ptr(0),
|
||||
DefaultAlertEvery: new(0),
|
||||
DefaultAlertDown: []string{"log_command"},
|
||||
},
|
||||
"override defaults",
|
||||
@@ -61,7 +60,7 @@ func TestDefaultConfig(t *testing.T) {
|
||||
m.Config{
|
||||
CheckInterval: 30 * time.Second,
|
||||
DefaultAlertAfter: 1,
|
||||
DefaultAlertEvery: Ptr(-1),
|
||||
DefaultAlertEvery: new(-1),
|
||||
DefaultAlertDown: []string{},
|
||||
},
|
||||
"default defaults",
|
||||
@@ -69,7 +68,6 @@ func TestDefaultConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -6,10 +6,6 @@ import (
|
||||
m "git.iamthefij.com/iamthefij/minitor-go/v2"
|
||||
)
|
||||
|
||||
func Ptr[T any](v T) *T {
|
||||
return &v
|
||||
}
|
||||
|
||||
// TestCheckConfig tests the checkConfig function
|
||||
// It also tests results for potentially invalid configuration. For example, no alerts
|
||||
func TestCheckMonitors(t *testing.T) {
|
||||
@@ -91,7 +87,6 @@ func TestCheckMonitors(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
@@ -171,7 +166,6 @@ func TestFirstRunAlerts(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
+3
-8
@@ -25,7 +25,6 @@ func TestMonitorValidate(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
@@ -103,7 +102,6 @@ func TestMonitorGetAlertNames(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
@@ -175,7 +173,6 @@ func TestMonitorFailureAlertAfter(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
@@ -204,15 +201,14 @@ func TestMonitorFailureAlertEvery(t *testing.T) {
|
||||
}{
|
||||
{m.Monitor{ShellCommand: "false", AlertAfter: 1}, []bool{true}, "No AlertEvery set"}, // Defaults to true because AlertAfter and AlertEvery default to nil
|
||||
// Alert first time only, after 1
|
||||
{m.Monitor{ShellCommand: "false", AlertAfter: 1, AlertEvery: Ptr(0)}, []bool{true, false, false}, "Alert first time only after 1"},
|
||||
{m.Monitor{ShellCommand: "false", AlertAfter: 1, AlertEvery: new(0)}, []bool{true, false, false}, "Alert first time only after 1"},
|
||||
// Alert every time, after 1
|
||||
{m.Monitor{ShellCommand: "false", AlertAfter: 1, AlertEvery: Ptr(1)}, []bool{true, true, true}, "Alert every time after 1"},
|
||||
{m.Monitor{ShellCommand: "false", AlertAfter: 1, AlertEvery: new(1)}, []bool{true, true, true}, "Alert every time after 1"},
|
||||
// Alert every other time, after 1
|
||||
{m.Monitor{ShellCommand: "false", AlertAfter: 1, AlertEvery: Ptr(2)}, []bool{true, false, true, false}, "Alert every other time after 1"},
|
||||
{m.Monitor{ShellCommand: "false", AlertAfter: 1, AlertEvery: new(2)}, []bool{true, false, true, false}, "Alert every other time after 1"},
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
@@ -301,7 +297,6 @@ func TestMonitorCheck(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -24,7 +24,6 @@ func TestUtilEqualSliceString(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
|
||||
t.Run(fmt.Sprintf("%v %v", c.a, c.b), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
Reference in New Issue
Block a user