Merge pull request 'golang-1-26' (#27) from golang-1-26 into main
Reviewed-on: https://git.iamthefij.com/iamthefij/minitor-go/pulls/27
This commit is contained in:
+9
-27
@@ -1,52 +1,34 @@
|
||||
version: "2"
|
||||
linters:
|
||||
enable:
|
||||
- errcheck
|
||||
- errname
|
||||
- errorlint
|
||||
- exhaustive
|
||||
- goprintffuncname
|
||||
- gosec
|
||||
- govet
|
||||
- ineffassign
|
||||
- misspell
|
||||
- mnd
|
||||
- tagliatelle
|
||||
- modernize
|
||||
- staticcheck
|
||||
- tagalign
|
||||
- testpackage
|
||||
- thelper
|
||||
- tparallel
|
||||
- unconvert
|
||||
- unused
|
||||
- wrapcheck
|
||||
- wsl
|
||||
disable:
|
||||
- gochecknoglobals
|
||||
settings:
|
||||
gosec:
|
||||
excludes:
|
||||
- G204
|
||||
tagliatelle:
|
||||
case:
|
||||
rules:
|
||||
json: snake
|
||||
yaml: snake
|
||||
- wsl_v5
|
||||
exclusions:
|
||||
generated: lax
|
||||
presets:
|
||||
- comments
|
||||
- common-false-positives
|
||||
- legacy
|
||||
- std-error-handling
|
||||
rules:
|
||||
- linters:
|
||||
- gosec
|
||||
path: _test\.go
|
||||
paths:
|
||||
- third_party$
|
||||
- builtin$
|
||||
- examples$
|
||||
formatters:
|
||||
enable:
|
||||
- gofumpt
|
||||
- goimports
|
||||
exclusions:
|
||||
generated: lax
|
||||
paths:
|
||||
- third_party$
|
||||
- builtin$
|
||||
- examples$
|
||||
|
||||
@@ -11,7 +11,7 @@ repos:
|
||||
- id: end-of-file-fixer
|
||||
- id: check-merge-conflict
|
||||
- repo: https://github.com/golangci/golangci-lint
|
||||
rev: v2.7.2
|
||||
rev: v2.10.1
|
||||
hooks:
|
||||
- id: golangci-lint
|
||||
- repo: https://github.com/hadolint/hadolint
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module git.iamthefij.com/iamthefij/minitor-go/v2
|
||||
|
||||
go 1.25.0
|
||||
go 1.26.0
|
||||
|
||||
require (
|
||||
git.iamthefij.com/iamthefij/slog/v2 v2.0.1
|
||||
|
||||
@@ -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