mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-30 13:35:23 +00:00
correctly update machine namespace
This commit is contained in:
parent
1b3a7bbf03
commit
6ba68d150c
@ -177,8 +177,10 @@ func (h *Headscale) SetMachineNamespace(machine *Machine, namespaceName string)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
machine.NamespaceID = namespace.ID
|
machine.Namespace = *namespace
|
||||||
h.db.Save(&machine)
|
if result := h.db.Save(&machine); result.Error != nil {
|
||||||
|
return result.Error
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -399,6 +399,7 @@ func (s *Suite) TestSetMachineNamespace(c *check.C) {
|
|||||||
err = app.SetMachineNamespace(&machine, newNamespace.Name)
|
err = app.SetMachineNamespace(&machine, newNamespace.Name)
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
c.Assert(machine.NamespaceID, check.Equals, newNamespace.ID)
|
c.Assert(machine.NamespaceID, check.Equals, newNamespace.ID)
|
||||||
|
c.Assert(machine.Namespace.Name, check.Equals, newNamespace.Name)
|
||||||
|
|
||||||
err = app.SetMachineNamespace(&machine, "non-existing-namespace")
|
err = app.SetMachineNamespace(&machine, "non-existing-namespace")
|
||||||
c.Assert(err, check.Equals, errNamespaceNotFound)
|
c.Assert(err, check.Equals, errNamespaceNotFound)
|
||||||
@ -406,4 +407,5 @@ func (s *Suite) TestSetMachineNamespace(c *check.C) {
|
|||||||
err = app.SetMachineNamespace(&machine, newNamespace.Name)
|
err = app.SetMachineNamespace(&machine, newNamespace.Name)
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
c.Assert(machine.NamespaceID, check.Equals, newNamespace.ID)
|
c.Assert(machine.NamespaceID, check.Equals, newNamespace.ID)
|
||||||
|
c.Assert(machine.Namespace.Name, check.Equals, newNamespace.Name)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user