Example #1
0
func (s *remoteSuite) TestWithDefaultsMissingName(c *gc.C) {
	remote := lxdclient.Remote{
		Name:     "",
		Host:     "some-host",
		Protocol: lxdclient.LXDProtocol,
		Cert:     s.Cert,
	}
	updated, err := remote.WithDefaults()
	c.Assert(err, jc.ErrorIsNil)

	c.Check(updated, jc.DeepEquals, remote) // Name is not updated.
}
Example #2
0
func (s *remoteSuite) TestWithDefaultsZeroValue(c *gc.C) {
	var remote lxdclient.Remote
	updated, err := remote.WithDefaults()
	c.Assert(err, jc.ErrorIsNil)
	err = updated.Validate()

	c.Check(err, jc.ErrorIsNil)
	c.Check(updated, jc.DeepEquals, lxdclient.Remote{
		Name:     "local",
		Host:     "",
		Protocol: lxdclient.LXDProtocol,
		Cert:     nil,
	})
}
Example #3
0
func (s *remoteSuite) TestWithDefaultsNoop(c *gc.C) {
	remote := lxdclient.Remote{
		Name:     "my-remote",
		Host:     "some-host",
		Protocol: lxdclient.LXDProtocol,
		Cert:     s.Cert,
	}
	updated, err := remote.WithDefaults()
	c.Assert(err, jc.ErrorIsNil)
	err = updated.Validate()

	c.Check(err, jc.ErrorIsNil)
	c.Check(updated, jc.DeepEquals, remote)
}
Example #4
0
func (s *remoteSuite) TestWithDefaultsMissingProtocol(c *gc.C) {
	remote := lxdclient.Remote{
		Name: "my-remote",
		Host: "some-host",
		Cert: s.Cert,
	}
	updated, err := remote.WithDefaults()
	c.Assert(err, jc.ErrorIsNil)
	err = updated.Validate()

	c.Check(err, jc.ErrorIsNil)
	c.Assert(updated.Cert, gc.NotNil)
	c.Check(updated.Cert.Validate(), jc.ErrorIsNil)
	updated.Cert = nil // Validate ensured that the cert was okay.
	c.Check(updated, jc.DeepEquals, lxdclient.Remote{
		Name:     "my-remote",
		Host:     "some-host",
		Protocol: lxdclient.LXDProtocol,
		Cert:     nil,
	})
}