Ejemplo n.º 1
0
func (s *envPayloadsSuite) TestListAllMulti(c *gc.C) {
	id1 := "f47ac10b-58cc-4372-a567-0e02b2c3d479"
	id2 := "f47ac10b-58cc-4372-a567-0e02b2c3d480"
	id3 := "f47ac10b-58cc-4372-a567-0e02b2c3d481"
	id4 := "f47ac10b-58cc-4372-a567-0e02b2c3d482"
	p1 := s.newPayload("spam")
	p2 := s.newPayload("eggs")
	p2.Unit = "a-service/1"
	p3 := s.newPayload("ham")
	p3.Unit = "a-service/2"
	p3.Machine = "2"
	p4 := s.newPayload("spamspamspam")
	p4.Unit = "a-service/1"
	s.persists.setPayload(id1, p1)
	s.persists.setPayload(id2, p2)
	s.persists.setPayload(id3, p3)
	s.persists.setPayload(id4, p4)

	ps := state.EnvPayloads{
		Persist: s.persists,
	}
	payloads, err := ps.ListAll()
	c.Assert(err, jc.ErrorIsNil)

	s.stub.CheckCallNames(c, "ListAll", "ListAll", "ListAll", "ListAll")
	checkPayloads(c, payloads, []payload.FullPayloadInfo{
		p1,
		p2,
		p3,
		p4,
	})
}
Ejemplo n.º 2
0
func (s *envPayloadsSuite) TestListAllFailed(c *gc.C) {
	id1 := "f47ac10b-58cc-4372-a567-0e02b2c3d479"
	id2 := "f47ac10b-58cc-4372-a567-0e02b2c3d480"
	failure := errors.Errorf("<failed!>")
	s.stub.SetErrors(failure)
	p1 := s.newPayload("spam")
	p2 := s.newPayload("eggs")
	s.persists.setPayload(id1, p1)
	s.persists.setPayload(id2, p2)

	ps := state.EnvPayloads{
		Persist: s.persists,
	}
	_, err := ps.ListAll()

	s.stub.CheckCallNames(c, "ListAll")
	c.Check(errors.Cause(err), gc.Equals, failure)
}
Ejemplo n.º 3
0
func (s *envPayloadsSuite) TestListAllOkay(c *gc.C) {
	id1 := "f47ac10b-58cc-4372-a567-0e02b2c3d479"
	id2 := "f47ac10b-58cc-4372-a567-0e02b2c3d480"
	p1 := s.newPayload("spam")
	p2 := s.newPayload("eggs")
	s.persists.setPayload(id1, p1)
	s.persists.setPayload(id2, p2)

	ps := state.EnvPayloads{
		Persist: s.persists,
	}
	payloads, err := ps.ListAll()
	c.Assert(err, jc.ErrorIsNil)

	s.stub.CheckCallNames(c, "ListAll", "ListAll")
	checkPayloads(c, payloads, []payload.FullPayloadInfo{
		p1,
		p2,
	})
}