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. }
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, }) }
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) }
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, }) }