cleanup function names
This commit is contained in:
parent
b368a97995
commit
8684aedbc2
2
main.go
2
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
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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")
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user