cleanup function names

This commit is contained in:
Tyrel Souza 2019-05-14 17:26:22 -04:00 committed by Tyrel Souza
parent b368a97995
commit 8684aedbc2
No known key found for this signature in database
GPG Key ID: 5A9394D4C30AEAC0
3 changed files with 8 additions and 10 deletions

View File

@ -43,7 +43,7 @@ func main() {
func scan(c *cli.Context) error {
directory := c.Args().First()
fmt.Println(strings.Join(getAllManifests(directory), ", "))
fmt.Println(strings.Join(getListOfManifestFilenames(directory), ", "))
// TODO, actually scan, don't just print names
return nil
}

View File

@ -10,7 +10,6 @@ import (
/*
When adding new manifest types, for new package managers
add a new entry here.
*/
func manifestGlobs() []string {
@ -112,12 +111,12 @@ func manifestGlobs() []string {
return globs
}
func getAllManifests(directory string) []string {
func getListOfManifestFilenames(directory string) []string {
matchingFiles := make([]string, 0)
for _, glob := range manifestGlobs() {
pathGlob := fmt.Sprintf("%s/**/%s", directory, glob)
files := getManifestGlobMatches(pathGlob)
files := getListOfGlobMatches(pathGlob)
if len(files) > 0 {
matchingFiles = append(matchingFiles, files...)
@ -126,7 +125,7 @@ func getAllManifests(directory string) []string {
return matchingFiles
}
func getManifestGlobMatches(glob string) []string {
func getListOfGlobMatches(glob string) []string {
files, err := doublestar.Glob(glob)
if err != nil {
log.Fatal(err)

View File

@ -7,31 +7,30 @@ import (
"github.com/stretchr/testify/assert"
)
func TestGetManifestGlobMatches(t *testing.T) {
func TestGetListOfGlobMatches(t *testing.T) {
//assert getManifestMatches gets all requirements.txt
expected := []string{
"test/fixtures/subdir/requirements.txt",
"test/fixtures/a/b/c/d/e/f/g/requirements.txt",
}
got := getManifestGlobMatches("test/**/requirements.txt")
got := getListOfGlobMatches("test/**/requirements.txt")
sort.Strings(expected)
sort.Strings(got)
assert.Equal(t, expected, got, "they should be equal")
}
func TestGetAllManifests(t *testing.T) {
func TestGetListOfManifestFilenames(t *testing.T) {
expected := []string{
"test/fixtures/yarn.lock",
"test/fixtures/Gemfile",
"test/fixtures/a/b/c/d/e/f/g/requirements.txt",
"test/fixtures/subdir/requirements.txt",
}
got := getAllManifests("test/")
got := getListOfManifestFilenames("test/")
sort.Strings(expected)
sort.Strings(got)
assert.Equal(t, expected, got, "they should match")
}