2019-05-14 03:26:13 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-05-15 02:09:14 +00:00
|
|
|
"os"
|
2019-05-14 21:16:59 +00:00
|
|
|
"sort"
|
2019-05-14 03:26:13 +00:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2019-05-14 21:26:22 +00:00
|
|
|
func TestGetListOfGlobMatches(t *testing.T) {
|
2019-05-14 03:26:13 +00:00
|
|
|
//assert getManifestMatches gets all requirements.txt
|
2019-05-15 03:20:16 +00:00
|
|
|
os.Chdir("test/good_config")
|
2019-05-14 03:26:13 +00:00
|
|
|
expected := []string{
|
2019-05-15 02:09:14 +00:00
|
|
|
"subdir/requirements.txt",
|
|
|
|
"a/b/c/d/e/f/g/requirements.txt",
|
2019-05-14 03:26:13 +00:00
|
|
|
}
|
2019-05-15 02:09:14 +00:00
|
|
|
got := getListOfGlobMatches("**/requirements.txt")
|
2019-05-14 21:16:59 +00:00
|
|
|
sort.Strings(expected)
|
|
|
|
sort.Strings(got)
|
2019-05-14 03:26:13 +00:00
|
|
|
|
|
|
|
assert.Equal(t, expected, got, "they should be equal")
|
|
|
|
}
|
|
|
|
|
2019-05-14 21:26:22 +00:00
|
|
|
func TestGetListOfManifestFilenames(t *testing.T) {
|
2019-05-14 21:16:59 +00:00
|
|
|
expected := []string{
|
2019-05-15 02:09:14 +00:00
|
|
|
"yarn.lock",
|
|
|
|
"Gemfile",
|
|
|
|
"a/b/c/d/e/f/g/requirements.txt",
|
|
|
|
"subdir/requirements.txt",
|
2019-05-14 03:26:13 +00:00
|
|
|
}
|
2019-05-15 03:20:16 +00:00
|
|
|
got := getListOfManifestFilenames("test/good_config")
|
2019-05-14 03:26:13 +00:00
|
|
|
|
2019-05-14 21:16:59 +00:00
|
|
|
sort.Strings(expected)
|
|
|
|
sort.Strings(got)
|
|
|
|
|
|
|
|
assert.Equal(t, expected, got, "they should match")
|
2019-05-14 03:26:13 +00:00
|
|
|
}
|