github.com/nak3/source-to-image@v1.1.10-0.20180319140719-2ed55639898d/pkg/scm/downloaders/file/download_test.go (about) 1 package file 2 3 import ( 4 "path/filepath" 5 "testing" 6 7 "github.com/openshift/source-to-image/pkg/api" 8 "github.com/openshift/source-to-image/pkg/scm/git" 9 testfs "github.com/openshift/source-to-image/pkg/test/fs" 10 ) 11 12 func TestDownload(t *testing.T) { 13 fs := &testfs.FakeFileSystem{} 14 f := &File{fs} 15 16 config := &api.Config{ 17 Source: git.MustParse("/foo"), 18 } 19 info, err := f.Download(config) 20 if err != nil { 21 t.Errorf("Unexpected error %v", err) 22 } 23 if fs.CopySource != "/foo" { 24 t.Errorf("Unexpected fs.CopySource %s", fs.CopySource) 25 } 26 if info.Location != config.Source.URL.Path || info.ContextDir != config.ContextDir { 27 t.Errorf("Unexpected info") 28 } 29 } 30 31 func TestDownloadWithContext(t *testing.T) { 32 fs := &testfs.FakeFileSystem{} 33 f := &File{fs} 34 35 config := &api.Config{ 36 Source: git.MustParse("/foo"), 37 ContextDir: "bar", 38 } 39 info, err := f.Download(config) 40 if err != nil { 41 t.Errorf("Unexpected error %v", err) 42 } 43 if filepath.ToSlash(fs.CopySource) != "/foo/bar" { 44 t.Errorf("Unexpected fs.CopySource %s", fs.CopySource) 45 } 46 if info.Location != config.Source.URL.Path || info.ContextDir != config.ContextDir { 47 t.Errorf("Unexpected info") 48 } 49 }