From 8684aedbc2ff5ecd6b97b29f440acd966b4195e5 Mon Sep 17 00:00:00 2001 From: Tyrel Souza Date: Tue, 14 May 2019 17:26:22 -0400 Subject: [PATCH] cleanup function names --- main.go | 2 +- manifests.go | 7 +++---- manifests_test.go | 9 ++++----- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/main.go b/main.go index 5e4a5b8..1d25500 100644 --- a/main.go +++ b/main.go @@ -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 } diff --git a/manifests.go b/manifests.go index 43ac30a..761fd07 100644 --- a/manifests.go +++ b/manifests.go @@ -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) diff --git a/manifests_test.go b/manifests_test.go index 6e826b0..c9e82af 100644 --- a/manifests_test.go +++ b/manifests_test.go @@ -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") - }