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
6 changes: 0 additions & 6 deletions pkg/workflow/config_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,6 @@ func ParseStringArrayOrExprFromConfig(m map[string]any, key string, log *logger.
return nil
}

// parseLabelsFromConfig extracts and validates labels from a config map
// Returns a slice of label strings, or nil if labels is not present or invalid
func parseLabelsFromConfig(configMap map[string]any) []string {
return ParseStringArrayFromConfig(configMap, "labels", configHelpersLog)
}

// extractStringFromMap is a generic helper that extracts and validates a string value from a map
// Returns the string value, or empty string if not present or invalid
Comment on lines 123 to 127
// If log is provided, it will log the extracted value for debugging
Expand Down
86 changes: 0 additions & 86 deletions pkg/workflow/config_parsing_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,92 +90,6 @@ func TestExtractStringFromMap(t *testing.T) {
}
}

func TestParseLabelsFromConfig(t *testing.T) {
tests := []struct {
name string
input map[string]any
expected []string
}{
{
name: "valid labels array",
input: map[string]any{
"labels": []any{"bug", "enhancement", "documentation"},
},
expected: []string{"bug", "enhancement", "documentation"},
},
{
name: "empty labels array",
input: map[string]any{
"labels": []any{},
},
expected: []string{},
},
{
name: "missing labels field",
input: map[string]any{},
expected: nil,
},
{
name: "labels with mixed types (filters non-strings)",
input: map[string]any{
"labels": []any{"bug", 123, "enhancement", true, "documentation"},
},
expected: []string{"bug", "enhancement", "documentation"},
},
{
name: "labels as []string",
input: map[string]any{
"labels": []string{"bug", "enhancement"},
},
expected: []string{"bug", "enhancement"},
},
{
name: "labels as non-array type",
input: map[string]any{
"labels": "not-an-array",
},
expected: nil,
},
{
name: "labels with only non-string types",
input: map[string]any{
"labels": []any{123, true, 456},
},
expected: []string{},
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := parseLabelsFromConfig(tt.input)

// Handle nil vs empty slice comparison
if tt.expected == nil {
if result != nil {
t.Errorf("expected nil, got %v", result)
}
return
}

if result == nil {
t.Errorf("expected %v, got nil", tt.expected)
return
}

if len(result) != len(tt.expected) {
t.Errorf("expected length %d, got %d", len(tt.expected), len(result))
return
}

for i, expected := range tt.expected {
if result[i] != expected {
t.Errorf("at index %d: expected %q, got %q", i, expected, result[i])
}
}
})
}
}

func TestParseTitlePrefixFromConfig(t *testing.T) {
tests := []struct {
name string
Expand Down
Loading