コード例 #1
0
ファイル: state_test.go プロジェクト: howbazaar/juju
func (suite *StateSuite) TestRemoveStateInstancesPartial(c *gc.C) {
	storage := suite.newStorage(c)
	state := common.BootstrapState{
		StateInstances: []instance.Id{
			instance.Id("a"),
			instance.Id("b"),
			instance.Id("c"),
		},
	}
	err := common.SaveState(storage, &state)
	c.Assert(err, jc.ErrorIsNil)

	err = common.RemoveStateInstances(
		storage,
		state.StateInstances[0],
		instance.Id("not-there"),
		state.StateInstances[2],
	)
	c.Assert(err, jc.ErrorIsNil)

	storedState, err := common.LoadState(storage)
	c.Assert(storedState, gc.DeepEquals, &common.BootstrapState{
		StateInstances: []instance.Id{
			state.StateInstances[1],
		},
	})
}
コード例 #2
0
ファイル: state_test.go プロジェクト: howbazaar/juju
func (suite *StateSuite) TestLoadStateIntegratesWithSaveState(c *gc.C) {
	storage := suite.newStorage(c)
	state := common.BootstrapState{
		StateInstances: []instance.Id{instance.Id("an-instance-id")},
	}
	err := common.SaveState(storage, &state)
	c.Assert(err, jc.ErrorIsNil)
	storedState, err := common.LoadState(storage)
	c.Assert(err, jc.ErrorIsNil)

	c.Check(*storedState, gc.DeepEquals, state)
}
コード例 #3
0
ファイル: environ_whitebox_test.go プロジェクト: bac/juju
func (suite *environSuite) TestControllerInstances(c *gc.C) {
	env := suite.makeEnviron()
	_, err := env.ControllerInstances(suite.controllerUUID)
	c.Assert(err, gc.Equals, environs.ErrNotBootstrapped)

	tests := [][]instance.Id{{}, {"inst-0"}, {"inst-0", "inst-1"}}
	for _, expected := range tests {
		err := common.SaveState(env.Storage(), &common.BootstrapState{
			StateInstances: expected,
		})
		c.Assert(err, jc.ErrorIsNil)
		controllerInstances, err := env.ControllerInstances(suite.controllerUUID)
		c.Assert(err, jc.ErrorIsNil)
		c.Assert(controllerInstances, jc.SameContents, expected)
	}
}
コード例 #4
0
ファイル: state_test.go プロジェクト: howbazaar/juju
func (suite *StateSuite) TestSaveStateWritesStateFile(c *gc.C) {
	stor := suite.newStorage(c)
	state := common.BootstrapState{
		StateInstances: []instance.Id{instance.Id("an-instance-id")},
	}
	marshaledState, err := goyaml.Marshal(state)
	c.Assert(err, jc.ErrorIsNil)

	err = common.SaveState(stor, &state)
	c.Assert(err, jc.ErrorIsNil)

	loadedState, err := storage.Get(stor, common.StateFile)
	c.Assert(err, jc.ErrorIsNil)
	content, err := ioutil.ReadAll(loadedState)
	c.Assert(err, jc.ErrorIsNil)
	c.Check(content, gc.DeepEquals, marshaledState)
}
コード例 #5
0
ファイル: state_test.go プロジェクト: howbazaar/juju
func (suite *StateSuite) TestRemoveStateInstancesNone(c *gc.C) {
	storage := suite.newStorage(c)
	state := common.BootstrapState{
		StateInstances: []instance.Id{instance.Id("an-instance-id")},
	}
	err := common.SaveState(storage, &state)
	c.Assert(err, jc.ErrorIsNil)

	err = common.RemoveStateInstances(
		storage,
		instance.Id("not-there"),
	)
	c.Assert(err, jc.ErrorIsNil)

	storedState, err := common.LoadState(storage)
	c.Assert(storedState, gc.DeepEquals, &state)
}