VictoriaMetrics/lib/promscrape/discovery/puppetdb/api_test.go
Zhu Jiekun f06c7e99fe
lib/promscrape: adds support for PuppetDB service discovery
This commit adds support for
[PuppetDB](https://www.puppet.com/docs/puppetdb/8/overview.html) service
discovery to the `vmagent` and `victoria-metrics-single` components.

Related issue https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5744
2024-10-27 20:38:34 +01:00

25 lines
864 B
Go

package puppetdb
import (
"testing"
)
func Test_newAPIConfig(t *testing.T) {
f := func(url, query string, includeParameters bool, port int, wantErr bool) {
t.Helper()
sdc := &SDConfig{
URL: url,
Query: query,
IncludeParameters: includeParameters,
Port: port,
}
if _, err := newAPIConfig(sdc, ""); wantErr != (err != nil) {
t.Fatalf("newAPIConfig want error = %t, but error = %v", wantErr, err)
}
}
f("https://puppetdb.example.com", `resources { type = "Class" and title = "Prometheus::Node_exporter" }`, true, 9100, false)
f("", `resources { type = "Class" and title = "Prometheus::Node_exporter" }`, true, 9100, true)
f("https://puppetdb.example.com", ``, true, 9100, true)
f("ftp://invalid.url", `resources { type = "Class" and title = "Prometheus::Node_exporter" }`, true, 9100, true)
}