func TestComponentUnmarshalYAML(t *testing.T) { s := `name: test tags: [] conflicts: [] cluster: false cluster_host_count: min: 0 threshold_healthy: 0 containers: []` var c Component if err := yaml.Unmarshal([]byte(s), &c); err != nil { t.Fatal(err) } if c.Name != "test" { t.Errorf("expecting \"Component.Name\" == \"test\", got \"%s\"", c.Name) } if c.Cluster { t.Error("expecting \"Component.Cluster\" to be false") } if c.ClusterHostCount.Min != 0 { t.Errorf("expecting \"Component.ClusterHostCount.Min\" == 0, got \"%d\"", c.ClusterHostCount.Min) } if c.ClusterHostCount.ThresholdHealthy != 0 { t.Errorf("expecting \"Component.ClusterHostCount.ThresholdHealthy\" == 0, got \"%d\"", c.ClusterHostCount.ThresholdHealthy) } }
func TestComponentUnmarshalYAMLCluster(t *testing.T) { s := `name: test tags: [] conflicts: [] cluster: true containers: []` var c Component if err := yaml.Unmarshal([]byte(s), &c); err != nil { t.Fatal(err) } if c.Name != "test" { t.Errorf("expecting \"Component.Name\" == \"test\", got \"%s\"", c.Name) } if !c.Cluster { t.Error("expecting \"Component.Cluster\" to be true") } if c.ClusterHostCount.Min != 1 { t.Errorf("expecting \"Component.ClusterHostCount.Min\" == 1, got \"%d\"", c.ClusterHostCount.Min) } if c.ClusterHostCount.ThresholdHealthy != 1 { t.Errorf("expecting \"Component.ClusterHostCount.ThresholdHealthy\" == 1, got \"%d\"", c.ClusterHostCount.ThresholdHealthy) } }
func TestContainerUnmarshalYAML(t *testing.T) { s := `source: public image_name: test display_name: Test Container version: "" privileged: false hostname: "" cmd: "" cluster: false publish_events: [] config_files: [] customer_files: [] env_vars: [] ports: [] volumes: [] support_files: [] support_commands: []` var c Container if err := yaml.Unmarshal([]byte(s), &c); err != nil { t.Fatal(err) } if c.Source != "public" { t.Errorf("expecting \"Container.Source\" == \"public\", got \"%s\"", c.Source) } if c.ImageName != "test" { t.Errorf("expecting \"Container.ImageName\" == \"test\", got \"%s\"", c.ImageName) } if c.DisplayName != "Test Container" { t.Errorf("expecting \"Container.DisplayName\" == \"Test Container\", got \"%s\"", c.ImageName) } if c.Cluster { t.Error("expecting \"Container.Cluster\" to be false") } if c.ClusterInstanceCount.Initial != 0 { t.Errorf("expecting \"Container.ClusterInstanceCount.Initial\" == 0, got \"%d\"", c.ClusterInstanceCount.Initial) } if c.ClusterInstanceCount.ThresholdHealthy != 0 { t.Errorf("expecting \"Container.ClusterInstanceCount.ThresholdHealthy\" == 0, got \"%d\"", c.ClusterInstanceCount.ThresholdHealthy) } }