Change ExpandFileSource to work with key=val patterns

Signed-off-by: Chris <chrismarkou92@gmail.com>
This commit is contained in:
Chris
2019-02-13 00:24:20 +02:00
committed by Chris Mark
parent e65b45f969
commit 1382d87d7f
2 changed files with 58 additions and 4 deletions

View File

@@ -102,3 +102,33 @@ func TestExpandFileSource(t *testing.T) {
t.Fatalf("FileSources is not correctly expanded: %v", fa.FileSources)
}
}
func TestExpandFileSourceWithKey(t *testing.T) {
fakeFS := fs.MakeFakeFS()
fakeFS.Create("dir/fa1")
fakeFS.Create("dir/reademe")
fa := flagsAndArgs{
FileSources: []string{"foo-key=dir/fa*"},
}
fa.ExpandFileSource(fakeFS)
expected := []string{
"foo-key=dir/fa1",
}
if !reflect.DeepEqual(fa.FileSources, expected) {
t.Fatalf("FileSources is not correctly expanded: %v", fa.FileSources)
}
}
func TestExpandFileSourceWithKeyAndError(t *testing.T) {
fakeFS := fs.MakeFakeFS()
fakeFS.Create("dir/fa1")
fakeFS.Create("dir/fa2")
fakeFS.Create("dir/reademe")
fa := flagsAndArgs{
FileSources: []string{"foo-key=dir/fa*"},
}
err := fa.ExpandFileSource(fakeFS)
if err == nil {
t.Fatalf("FileSources should not be correctly expanded: %v", fa.FileSources)
}
}