func (fp *FakePersistor) Load(data configuration.DataInterface) (err error) {
	if fp.LoadReturns.Data == nil {
		fp.LoadReturns.Data = core_config.NewData()
	}
	data = fp.LoadReturns.Data
	err = fp.LoadReturns.Err
	return
}
示例#2
0
func (fp *FakePersistor) Load(data configuration.DataInterface) error {
	if fp.LoadReturns.Data == nil {
		fp.LoadReturns.Data = core_config.NewData()
	}
	return fp.LoadReturns.Err
}
示例#3
0
				},
			}

			jsonData, err := data.JsonMarshalV3()
			Expect(err).NotTo(HaveOccurred())

			re := regexp.MustCompile(`\s+`)
			actual := re.ReplaceAll(jsonData, []byte{})
			expected := re.ReplaceAll([]byte(exampleV3JSON), []byte{})
			Expect(actual).To(Equal(expected))
		})
	})

	Describe("JsonUnmarshalV3", func() {
		It("returns an error when the JSON is invalid", func() {
			configData := core_config.NewData()
			err := configData.JsonUnmarshalV3([]byte(`{ "not_valid": ### }`))
			Expect(err).To(HaveOccurred())
		})

		It("creates a config object from valid V3 JSON", func() {
			expectedData := &core_config.Data{
				ConfigVersion:            3,
				Target:                   "api.example.com",
				ApiVersion:               "3",
				AuthorizationEndpoint:    "auth.example.com",
				LoggregatorEndPoint:      "loggregator.example.com",
				RoutingApiEndpoint:       "routing-api.example.com",
				DopplerEndPoint:          "doppler.example.com",
				UaaEndpoint:              "uaa.example.com",
				AccessToken:              "the-access-token",