mirror of
https://github.com/TecharoHQ/anubis.git
synced 2026-04-27 18:42:41 +00:00
feat(config): add metrics bind config to policy file with flag hack
Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMetricsValid(t *testing.T) {
|
||||
for _, tt := range []struct {
|
||||
name string
|
||||
input *Metrics
|
||||
err error
|
||||
}{
|
||||
{
|
||||
name: "basic TCP",
|
||||
input: &Metrics{
|
||||
Bind: ":9090",
|
||||
Network: "tcp",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "no bind",
|
||||
input: &Metrics{},
|
||||
err: ErrNoMetricsBind,
|
||||
},
|
||||
{
|
||||
name: "no network",
|
||||
input: &Metrics{},
|
||||
err: ErrNoMetricsNetwork,
|
||||
},
|
||||
{
|
||||
name: "invalid network",
|
||||
input: &Metrics{
|
||||
Bind: ":9090",
|
||||
Network: "taco",
|
||||
},
|
||||
err: ErrInvalidMetricsNetwork,
|
||||
},
|
||||
} {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if err := tt.input.Valid(); !errors.Is(err, tt.err) {
|
||||
t.Logf("wanted error: %v", tt.err)
|
||||
t.Logf("got error: %v", err)
|
||||
t.Error("validation failed")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user