func populateDB(t *testing.T) { if err := sqlstore.AddProbe(&m.ProbeDTO{ Name: "dev1", Tags: []string{"tag1", "tag2"}, OrgId: 10, }); err != nil { t.Fatal(err) } if err := sqlstore.AddEndpoint(&m.EndpointDTO{ Name: "dev2", Tags: []string{"Dev"}, OrgId: 10, }); err != nil { t.Fatal(err) } }
func V1AddCollector(c *middleware.Context, probe m.ProbeDTO) { probe.OrgId = c.OrgId if probe.Id != 0 { c.JSON(400, "Id already set. Try update instead of create.") return } if probe.Name == "" { c.JSON(400, "Collector Name not set.") return } if err := sqlstore.AddProbe(&probe); err != nil { handleError(c, err) return } c.JSON(200, probe) return }