示例#1
0
func (s *instanceSuite) TestInstanceRefresh(c *gc.C) {
	s.FakeConn.Instance = &s.RawInstanceFull

	specBefore := google.GetInstanceSpec(&s.Instance)
	err := s.Instance.Refresh(s.Conn)
	c.Assert(err, jc.ErrorIsNil)
	specAfter := google.GetInstanceSpec(&s.Instance)

	c.Check(s.Instance.ID, gc.Equals, "spam")
	c.Check(s.Instance.ZoneName, gc.Equals, "a-zone")
	c.Check(s.Instance.Status(), gc.Equals, google.StatusRunning)
	c.Check(s.Instance.Metadata(), jc.DeepEquals, s.Metadata)
	c.Check(s.Instance.Addresses(), jc.DeepEquals, s.Addresses)
	c.Check(specAfter, gc.Equals, specBefore)
}
示例#2
0
func (s *instanceSuite) TestNewInstance(c *gc.C) {
	inst := google.NewInstanceRaw(&s.RawInstanceFull, &s.InstanceSpec)

	c.Check(inst.ID, gc.Equals, "spam")
	c.Check(inst.ZoneName, gc.Equals, "a-zone")
	c.Check(inst.Status(), gc.Equals, google.StatusRunning)
	c.Check(inst.Metadata(), jc.DeepEquals, s.Metadata)
	c.Check(inst.Addresses(), jc.DeepEquals, s.Addresses)
	spec := google.GetInstanceSpec(inst)
	c.Check(spec, jc.DeepEquals, &s.InstanceSpec)
}
示例#3
0
func (s *instanceSuite) TestConnectionAddInstance(c *gc.C) {
	s.FakeConn.Instance = &s.RawInstanceFull

	inst, err := s.Conn.AddInstance(s.InstanceSpec, "a-zone")
	c.Assert(err, jc.ErrorIsNil)

	c.Check(inst.ID, gc.Equals, "spam")
	c.Check(inst.ZoneName, gc.Equals, "a-zone")
	c.Check(inst.Status(), gc.Equals, google.StatusRunning)
	c.Check(inst.Metadata(), jc.DeepEquals, s.Metadata)
	c.Check(inst.Addresses(), jc.DeepEquals, s.Addresses)
	spec := google.GetInstanceSpec(inst)
	c.Check(spec, gc.DeepEquals, &s.InstanceSpec)
}
示例#4
0
func (s *instanceSuite) TestNewInstanceNoSpec(c *gc.C) {
	inst := google.NewInstanceRaw(&s.RawInstanceFull, nil)

	spec := google.GetInstanceSpec(inst)
	c.Check(spec, gc.IsNil)
}