Skip to content

Commit

Permalink
add unit test for csv method
Browse files Browse the repository at this point in the history
  • Loading branch information
jaxxstorm committed Nov 4, 2023
1 parent b02b086 commit dc7ba65
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions provider/pkg/provider/aws/bastion_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package aws

import (
"testing"
)

func TestUserDataArgs_JoinedTags(t *testing.T) {
type fields struct {
ParameterName string
Route string
Region string
TailscaleTags []string
}
tests := []struct {
name string
fields fields
want string
}{
{
name: "no tags",
fields: fields{
TailscaleTags: []string{},
},
want: "",
},
{
name: "single tag",
fields: fields{
TailscaleTags: []string{"tag1"},
},
want: "tag:tag1",
},
{
name: "multiple tags",
fields: fields{
TailscaleTags: []string{"tag1", "tag2", "tag3"},
},
want: "tag:tag1,tag:tag2,tag:tag3",
},
{
name: "tags with spaces",
fields: fields{
TailscaleTags: []string{"tag 1", "tag 2"},
},
want: "tag:tag 1,tag:tag 2",
},
{
name: "tags with special characters",
fields: fields{
TailscaleTags: []string{"tag-1", "tag@2", "tag#3"},
},
want: "tag:tag-1,tag:tag@2,tag:tag#3",
},
{
name: "nil slice",
fields: fields{
TailscaleTags: nil,
},
want: "",
},
{
name: "slice with empty strings",
fields: fields{
TailscaleTags: []string{"", ""},
},
want: "tag:,tag:",
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
uda := &UserDataArgs{
ParameterName: tt.fields.ParameterName,
Route: tt.fields.Route,
Region: tt.fields.Region,
TailscaleTags: tt.fields.TailscaleTags,
}
if got := uda.JoinedTags(); got != tt.want {
t.Errorf("UserDataArgs.JoinedTags() = %v, want %v", got, tt.want)
}
})
}
}

0 comments on commit dc7ba65

Please sign in to comment.