mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-21 07:56:26 +01:00
ea153e5f90
* vmagent: add test for marshalling gce sdconfig with ZoneYAML * vmagent: implement MarshalYAML for ZoneYAML on gce sdconfig
28 lines
521 B
Go
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)
|
|
}
|
|
}
|