Adding another test case and running go fmt

This commit is contained in:
Brandon Mendrick 2021-04-21 22:42:24 -05:00
parent 53df3e1140
commit 4ddb67df3c
2 changed files with 19 additions and 15 deletions

View file

@ -43,18 +43,18 @@ func doList(c *cli.Context) error {
query = strings.Join(paths[1:], "/")
host = paths[0]
}
// Using smartcase searching
if strings.ToLower(query) == query {
filterByQuery = func(repo *LocalRepository) bool {
return strings.Contains(strings.ToLower(repo.NonHostPath()), query) &&
(host == "" || repo.PathParts[0] == host)
}
} else {
filterByQuery = func(repo *LocalRepository) bool {
return strings.Contains(repo.NonHostPath(), query) &&
(host == "" || repo.PathParts[0] == host)
}
}
// Using smartcase searching
if strings.ToLower(query) == query {
filterByQuery = func(repo *LocalRepository) bool {
return strings.Contains(strings.ToLower(repo.NonHostPath()), query) &&
(host == "" || repo.PathParts[0] == host)
}
} else {
filterByQuery = func(repo *LocalRepository) bool {
return strings.Contains(repo.NonHostPath(), query) &&
(host == "" || repo.PathParts[0] == host)
}
}
}
}

View file

@ -82,9 +82,9 @@ func TestDoList_query(t *testing.T) {
"github.com/motemen/gobump",
"github.com/motemen/gore",
"github.com/Songmu/gobump",
"github.com/test/Awesome",
"github.com/test/awesome",
"github.com/test/AwEsOmE",
"github.com/test/Awesome",
"github.com/test/awesome",
"github.com/test/AwEsOmE",
"golang.org/x/crypt",
"golang.org/x/image",
}
@ -143,6 +143,10 @@ func TestDoList_query(t *testing.T) {
name: "smartcasing exact",
args: []string{"Awesome"},
expect: "github.com/test/Awesome\n",
}, {
name: "smartcasing exact fail",
args: []string{"aWesome"},
expect: "",
}}
withFakeGitBackend(t, func(t *testing.T, tmproot string, _ *_cloneArgs, _ *_updateArgs) {