Skip to content

Commit

Permalink
Merge pull request #341 from wakatime/feature/test-multiline
Browse files Browse the repository at this point in the history
Add test for multine submodules
  • Loading branch information
gandarez authored May 3, 2021
2 parents b4e7c5c + bd5007f commit adff70e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 4 additions & 0 deletions cmd/legacy/heartbeat/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,10 @@ func parseBoolOrRegexList(s string) ([]regex.Regex, error) {
default:
splitted := strings.Split(s, "\n")
for _, s := range splitted {
if s == "" {
continue
}

compiled, err := regex.Compile(s)
if err != nil {
return nil, fmt.Errorf("failed to compile regex %q: %s", s, err)
Expand Down
7 changes: 3 additions & 4 deletions cmd/legacy/heartbeat/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/wakatime/wakatime-cli/pkg/heartbeat"
"github.com/wakatime/wakatime-cli/pkg/project"
"github.com/wakatime/wakatime-cli/pkg/regex"
"gopkg.in/ini.v1"

"github.com/spf13/pflag"
"github.com/spf13/viper"
Expand Down Expand Up @@ -1724,9 +1725,6 @@ func TestLoadParams_DisableSubmodule_False(t *testing.T) {
}

func TestLoadParams_DisableSubmodule_List(t *testing.T) {
// https://github.com/go-ini/ini/issues/270
t.Skip("Skipping because ini parser does not support parsing multiple lines yet")

tests := map[string]struct {
ViperValue string
Expected []regex.Regex
Expand All @@ -1748,7 +1746,8 @@ func TestLoadParams_DisableSubmodule_List(t *testing.T) {

for name, test := range tests {
t.Run(name, func(t *testing.T) {
v := viper.New()
multilineOption := viper.IniLoadOptions(ini.LoadOptions{AllowPythonMultilineValues: true})
v := viper.NewWithOptions(multilineOption)
v.Set("key", "00000000-0000-4000-8000-000000000000")
v.Set("entity", "/path/to/file")
v.Set("git.submodules_disabled", test.ViperValue)
Expand Down
2 changes: 1 addition & 1 deletion pkg/project/subversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,6 @@ func findSvnBinary() (string, bool) {
func skipIfBinaryNotFound(t *testing.T) {
_, found := findSvnBinary()
if !found {
t.Skip("Skipping because the lack of svn binary in this machine.")
t.Skip("Skipping because svn binary is not installed in this machine.")
}
}

0 comments on commit adff70e

Please sign in to comment.