headscale/machine_test.go

37 lines
734 B
Go
Raw Normal View History

2021-05-12 00:55:36 +00:00
package headscale
import (
"gopkg.in/check.v1"
)
func (s *Suite) TestGetMachine(c *check.C) {
n, err := h.CreateNamespace("test")
c.Assert(err, check.IsNil)
pak, err := h.CreatePreAuthKey(n.Name, false, false, nil)
2021-05-12 00:55:36 +00:00
c.Assert(err, check.IsNil)
_, err = h.GetMachine("test", "testmachine")
c.Assert(err, check.NotNil)
m := Machine{
ID: 0,
MachineKey: "foo",
NodeKey: "bar",
DiscoKey: "faa",
Name: "testmachine",
NamespaceID: n.ID,
Registered: true,
RegisterMethod: "authKey",
AuthKeyID: uint(pak.ID),
}
2021-07-04 19:40:46 +00:00
h.db.Save(&m)
2021-05-12 00:55:36 +00:00
m1, err := h.GetMachine("test", "testmachine")
c.Assert(err, check.IsNil)
_, err = m1.GetHostInfo()
c.Assert(err, check.IsNil)
}