Merge pull request #7789 from influxdata/mr-monitor-config-validation
Require database name on monitor configpull/7781/head^2
commit
bbbf9d9711
|
@ -40,5 +40,8 @@ func (c Config) Validate() error {
|
||||||
if c.StoreInterval <= 0 {
|
if c.StoreInterval <= 0 {
|
||||||
return errors.New("monitor store interval must be positive")
|
return errors.New("monitor store interval must be positive")
|
||||||
}
|
}
|
||||||
|
if c.StoreDatabase == "" {
|
||||||
|
return errors.New("monitor store database name must not be empty")
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,3 +28,25 @@ store-interval="10m"
|
||||||
t.Fatalf("unexpected store-interval: %s", c.StoreInterval)
|
t.Fatalf("unexpected store-interval: %s", c.StoreInterval)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestConfig_Validate(t *testing.T) {
|
||||||
|
// NewConfig must validate correctly.
|
||||||
|
c := monitor.NewConfig()
|
||||||
|
if err := c.Validate(); err != nil {
|
||||||
|
t.Fatalf("unexpected validation error: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Non-positive duration is invalid.
|
||||||
|
c = monitor.NewConfig()
|
||||||
|
c.StoreInterval *= 0
|
||||||
|
if err := c.Validate(); err == nil {
|
||||||
|
t.Fatalf("unexpected successful validation for %#v", c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Empty database is invalid.
|
||||||
|
c = monitor.NewConfig()
|
||||||
|
c.StoreDatabase = ""
|
||||||
|
if err := c.Validate(); err == nil {
|
||||||
|
t.Fatalf("unexpected successful validation for %#v", c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue