mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-11 14:53:49 +00:00
f3be3573e7
- Sort the discovered labels in alphabetical order at https://docs.victoriametrics.com/sd_configs/#vultr_sd_configs - Rename VultrConfigs to VultrSDConfigs to be consistent with the naming for other SD configs. - Prepare query arg filters for `list instances API` at newAPIConfig() instead of passing them in a separate listParams struct. This simplifies the code a bit. - Return error when bearer token isn't set at vultr_sd_configs, since this token is mandatory according to https://docs.victoriametrics.com/sd_configs/#vultr_sd_configs - Remove unused fields from the parsed response from Vultr list instances API in order to simplify the code a bit. - Remove double logging of errors inside getInstances() function, since these errors must be already logged by the caller. - Simplify tests, so they are easier to maintain. Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/6041 Updates https://github.com/VictoriaMetrics/VictoriaMetrics/pull/6068
31 lines
585 B
Go
31 lines
585 B
Go
package vultr
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/promauth"
|
|
)
|
|
|
|
func TestNewAPIConfig_Failure(t *testing.T) {
|
|
sdc := &SDConfig{}
|
|
baseDir := "."
|
|
_, err := newAPIConfig(sdc, baseDir)
|
|
if err == nil {
|
|
t.Fatalf("expecting non-nil error")
|
|
}
|
|
}
|
|
|
|
func TestNewAPIConfig_Success(t *testing.T) {
|
|
sdc := &SDConfig{
|
|
HTTPClientConfig: promauth.HTTPClientConfig{
|
|
BearerToken: &promauth.Secret{
|
|
S: "foobar",
|
|
},
|
|
},
|
|
}
|
|
baseDir := "."
|
|
_, err := newAPIConfig(sdc, baseDir)
|
|
if err != nil {
|
|
t.Fatalf("newAPIConfig failed with, err: %v", err)
|
|
}
|
|
}
|