func CreateBmpClient() (clients.BmpClient, error) { currentUser, err := user.Current() if err != nil { return nil, err } c := config.NewConfig(filepath.Join(currentUser.HomeDir, config.CONFIG_FILE_NAME)) configInfo, err := c.LoadConfig() if err != nil { return nil, err } return clients.NewBmpClient(configInfo.Username, configInfo.Password, configInfo.TargetUrl, nil, c.Path()), nil }
var ( err error bmpClient clients.BmpClient fakeHttpClient *slclientfakes.FakeHttpClient fakeServerSpec clients.ServerSpec fakeCloudProperty []clients.CloudProperty fakeCreateBaremetalsInfo clients.CreateBaremetalsInfo fakeProvisioningBaremetalInfo clients.ProvisioningBaremetalInfo ) BeforeEach(func() { fakeHttpClient = slclientfakes.NewFakeHttpClient("fake-username", "fake-password") Expect(fakeHttpClient).ToNot(BeNil()) bmpClient = clients.NewBmpClient("fake-username", "fake-password", "http://fake.url.com", fakeHttpClient, "fake-config-path") Expect(bmpClient).ToNot(BeNil()) }) Describe("#ConfigPath", func() { It("returns the ConfigPath", func() { configPath := bmpClient.ConfigPath() Expect(configPath).To(Equal("fake-config-path")) }) }) Describe("#Info", func() { BeforeEach(func() { fakeHttpClient.DoRawHttpRequestResponse, err = common.ReadJsonTestFixtures("..", "bmp", "Info.json") Expect(err).ToNot(HaveOccurred()) })