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

	c.Check(updated, jc.DeepEquals, remote) // Name is not updated.
}
Exemplo n.º 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: "",
		Cert: nil,
	})
}
Exemplo n.º 3
0
func (s *remoteSuite) TestWithDefaultsNoop(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.Check(updated, jc.DeepEquals, remote)
}
Exemplo n.º 4
0
func (s *remoteSuite) TestWithDefaultsLocalNoop(c *gc.C) {
	remote := lxdclient.Remote{
		Name: "my-local",
		Host: "",
		Cert: nil,
	}
	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: "my-local",
		Host: "",
		Cert: nil,
	})
}
Exemplo n.º 5
0
// TODO(ericsnow) Move this test to a functional suite.
func (s *remoteSuite) TestWithDefaultsMissingCert(c *gc.C) {
	remote := lxdclient.Remote{
		Name: "my-remote",
		Host: "some-host",
		Cert: nil,
	}
	err := remote.Validate()
	c.Assert(err, gc.NotNil) // Make sure the original is invalid.

	updated, err := remote.WithDefaults()
	c.Assert(err, jc.ErrorIsNil)
	err = updated.Validate()

	c.Check(err, 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",
		Cert: nil,
	})
}