Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(exp): add AppendNextActions function #440

Merged
merged 4 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
11 changes: 11 additions & 0 deletions hcloud/exp/kit/actions/actions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package actions
jooola marked this conversation as resolved.
Show resolved Hide resolved

import "github.com/hetznercloud/hcloud-go/v2/hcloud"

// AppendNextActions return the action and the next actions in a new slice.
func AppendNextActions(action *hcloud.Action, nextActions []*hcloud.Action) []*hcloud.Action {
all := make([]*hcloud.Action, 0, 1+len(nextActions))
all = append(all, action)
all = append(all, nextActions...)
return all
}
18 changes: 18 additions & 0 deletions hcloud/exp/kit/actions/actions_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package actions

import (
"testing"

"github.com/stretchr/testify/assert"

"github.com/hetznercloud/hcloud-go/v2/hcloud"
)

func TestAppendNextActions(t *testing.T) {
action := &hcloud.Action{ID: 1}
nextActions := []*hcloud.Action{{ID: 2}, {ID: 3}}

actions := AppendNextActions(action, nextActions)

assert.Equal(t, []*hcloud.Action{{ID: 1}, {ID: 2}, {ID: 3}}, actions)
}