コード例 #1
0
ファイル: asset_test.go プロジェクト: contiv/cluster
func (s *inventorySuite) TestSetStatus(c *C) {
	ctrl := gomock.NewController(c)
	defer ctrl.Finish()

	mClient := mock.NewMockSubsysClient(ctrl)
	asset := &Asset{
		client:     mClient,
		name:       "foo",
		status:     Unallocated,
		prevStatus: Incomplete,
		state:      Discovered,
		prevState:  Unknown,
	}
	eAsset := &Asset{
		client:     mClient,
		name:       "foo",
		status:     Provisioning,
		prevStatus: Unallocated,
		state:      Disappeared,
		prevState:  Discovered,
	}
	mClient.EXPECT().SetAssetStatus(asset.name, eAsset.status.String(),
		eAsset.state.String(), StateDescription[eAsset.state])
	err := asset.SetStatus(eAsset.status, eAsset.state)
	c.Assert(err, IsNil)
	c.Assert(asset, DeepEquals, eAsset)
}
コード例 #2
0
ファイル: asset_test.go プロジェクト: contiv/cluster
func (s *inventorySuite) TestSetStatusSetFailure(c *C) {
	ctrl := gomock.NewController(c)
	defer ctrl.Finish()

	mClient := mock.NewMockSubsysClient(ctrl)
	asset := &Asset{
		client:     mClient,
		name:       "foo",
		status:     Unallocated,
		prevStatus: Incomplete,
		state:      Discovered,
		prevState:  Unknown,
	}
	eAsset := &Asset{
		client:     mClient,
		name:       "foo",
		status:     Unallocated,
		prevStatus: Incomplete,
		state:      Discovered,
		prevState:  Unknown,
	}
	mClient.EXPECT().SetAssetStatus(asset.name, Provisioning.String(),
		Discovered.String(), StateDescription[asset.state]).Return(errored.Errorf("test failure"))
	err := asset.SetStatus(Provisioning, Discovered)
	c.Assert(err, NotNil)
	c.Assert(asset, DeepEquals, eAsset)
}
コード例 #3
0
ファイル: asset_test.go プロジェクト: contiv/cluster
func (s *inventorySuite) TestNewAssetCreateFailure(c *C) {
	ctrl := gomock.NewController(c)
	defer ctrl.Finish()

	mClient := mock.NewMockSubsysClient(ctrl)
	eAsset := &Asset{
		client:     mClient,
		name:       "foo",
		status:     Unallocated,
		prevStatus: Incomplete,
		state:      Discovered,
		prevState:  Unknown,
	}
	mClient.EXPECT().CreateAsset(eAsset.name,
		eAsset.status.String()).Return(errored.Errorf("test error"))
	_, err := NewAsset(mClient, eAsset.name)
	c.Assert(err, NotNil)
}