VictoriaMetrics/lib/promscrape/discovery/gce/gce_test.go
Aliaksandr Valialkin 123aa4c79e
lib/promscrape: properly implement ScrapeConfig.clone()
Previously ScrapeConfig.clone() was improperly copying promauth.Secret fields -
their contents was replaced with `<secret>` value.

This led to inability to use passwords and secrets in `-promscrape.config` file.
The bug has been introduced in v1.77.0 in the commit 67b10896d2

Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2551
2022-05-07 00:05:40 +03:00

28 lines
521 B
Go

package gce
import (
"testing"
"gopkg.in/yaml.v2"
)
func TestMarshallingSDConfigWithZoneYAML(t *testing.T) {
sdConfig := SDConfig{
Project: "test-project",
Zone: ZoneYAML{
Zones: []string{"zone-a", "zone-b"},
},
}
data, err := yaml.Marshal(sdConfig)
if err != nil {
t.Fatalf("unexpected non-nil error")
}
strData := string(data)
expected := "project: test-project\nzone:\n- zone-a\n- zone-b\n"
if strData != expected {
t.Fatalf("unexpected marshal:\ngot \n%vwant\n%v", strData, expected)
}
}