Skip to content

Commit

Permalink
Merge pull request #6 from takumakume/fix-tags-comma
Browse files Browse the repository at this point in the history
Convert to Slice if Project Tags are passed comma separated
  • Loading branch information
takumakume authored Nov 22, 2023
2 parents 29ca9b7 + a4e9260 commit 5e33774
Showing 2 changed files with 25 additions and 1 deletion.
9 changes: 8 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package config

import "errors"
import (
"errors"
"strings"
)

type Config struct {
BaseURL string
@@ -14,6 +17,10 @@ type Config struct {
var ErrAPIKeyIsRequired = errors.New("api-key is required")

func New(baseURL, apiKey, projectName, projectVersion string, projectTags []string) *Config {
if len(projectTags) == 1 && strings.Contains(projectTags[0], ",") {
projectTags = strings.Split(projectTags[0], ",")
}

return &Config{
BaseURL: baseURL,
APIKey: apiKey,
17 changes: 17 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
@@ -35,6 +35,23 @@ func TestNew(t *testing.T) {
ProjectTags: []string{"tag1", "tag2"},
},
},
{
name: "success tag separator is comma",
args: args{
baseURL: "https://example.com",
apiKey: "12345",
projectName: "test-project",
projectVersion: "1.0.0",
projectTags: []string{"tag1,tag2"},
},
want: &Config{
BaseURL: "https://example.com",
APIKey: "12345",
ProjectName: "test-project",
ProjectVersion: "1.0.0",
ProjectTags: []string{"tag1", "tag2"},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {

0 comments on commit 5e33774

Please sign in to comment.