Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client/board.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ type BoardPanelPosition struct {
}

type BoardQueryPanel struct {
Dataset string `json:"dataset,omitempty"`
QueryID string `json:"query_id,omitempty"`
QueryAnnotationID string `json:"query_annotation_id,omitempty"`
VisualizationSettings *BoardQueryVisualizationSettings `json:"visualization_settings,omitempty"`
Expand Down
24 changes: 24 additions & 0 deletions client/board_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,14 @@ func TestFlexibleBoards(t *testing.T) {
assert.NotEmpty(t, flexibleBoard.Links.BoardURL)
data.Links.BoardURL = flexibleBoard.Links.BoardURL

// copy dataset name into query panel for comparison
for i, panel := range flexibleBoard.Panels {
if panel.PanelType == client.BoardPanelTypeQuery {
assert.Equal(t, dataset, panel.QueryPanel.Dataset)
data.Panels[i].QueryPanel.Dataset = dataset
}
}

assert.Equal(t, data, flexibleBoard)
})

Expand Down Expand Up @@ -282,6 +290,14 @@ func TestFlexibleBoards(t *testing.T) {
assert.NotEmpty(t, flexibleBoard.Links.BoardURL)
data.Links.BoardURL = flexibleBoard.Links.BoardURL

// copy dataset name into query panel for comparison
for i, panel := range flexibleBoard.Panels {
if panel.PanelType == client.BoardPanelTypeQuery {
assert.Equal(t, dataset, panel.QueryPanel.Dataset)
data.Panels[i].QueryPanel.Dataset = dataset
}
}

for i, panel := range flexibleBoard.Panels {
assert.Equal(t, data.Panels[i].PanelType, panel.PanelType)
assert.Equal(t, data.Panels[i].QueryPanel, panel.QueryPanel)
Expand Down Expand Up @@ -345,6 +361,14 @@ func TestFlexibleBoards(t *testing.T) {
assert.NotEmpty(t, flexibleBoard.Links.BoardURL)
data.Links.BoardURL = flexibleBoard.Links.BoardURL

// copy dataset name into query panel for comparison
for i, panel := range flexibleBoard.Panels {
if panel.PanelType == client.BoardPanelTypeQuery {
assert.Equal(t, dataset, panel.QueryPanel.Dataset)
data.Panels[i].QueryPanel.Dataset = dataset
}
}

// ensure the tags were added
assert.NotEmpty(t, flexibleBoard.Tags)
assert.ElementsMatch(t, flexibleBoard.Tags, data.Tags, "tags do not match")
Expand Down
30 changes: 30 additions & 0 deletions internal/provider/honeycombio_sweeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func TestMain(m *testing.M) {
}

func init() {
resource.AddTestSweepers("boards", getBoardSweeper("boards"))
resource.AddTestSweepers("datasets", getDatasetSweeper("datasets"))
resource.AddTestSweepers("environments", getEnvironmentSweeper("environments"))
resource.AddTestSweepers("recipients", getRecipientSweeper("recipients"))
Expand Down Expand Up @@ -157,3 +158,32 @@ func getRecipientSweeper(name string) *resource.Sweeper {
},
}
}

func getBoardSweeper(name string) *resource.Sweeper {
return &resource.Sweeper{
Name: name,
F: func(_ string) error {
ctx := context.Background()
c, err := client.NewClient()
if err != nil {
return fmt.Errorf("could not initialize client: %w", err)
}
boards, err := c.Boards.List(ctx)
if err != nil {
return fmt.Errorf("could not list boards: %w", err)
}

for _, b := range boards {
if strings.HasPrefix(b.Name, SweeperTargetPrefix) {
log.Printf("[DEBUG] deleting board %s (%s)", b.Name, b.ID)
err = c.Boards.Delete(ctx, b.ID)
if err != nil {
log.Printf("[ERROR] could not delete board %s: %s", b.ID, err)
}
}
}

return nil
},
}
}