gopkg.in/openshift/source-to-image.v1@v1.2.0/pkg/test/download.go (about)

     1  package test
     2  
     3  import (
     4  	"net/url"
     5  	"sync"
     6  
     7  	"github.com/openshift/source-to-image/pkg/scm/git"
     8  )
     9  
    10  // FakeDownloader provides a fake downloader interface
    11  type FakeDownloader struct {
    12  	URL    []url.URL
    13  	Target []string
    14  	Err    map[string]error
    15  	mutex  sync.Mutex
    16  }
    17  
    18  // Download downloads a fake file from the URL
    19  func (f *FakeDownloader) Download(url *url.URL, target string) (*git.SourceInfo, error) {
    20  	f.mutex.Lock()
    21  	defer f.mutex.Unlock()
    22  
    23  	f.URL = append(f.URL, *url)
    24  	f.Target = append(f.Target, target)
    25  
    26  	return &git.SourceInfo{Location: target, CommitID: "1bf4f04"}, f.Err[url.String()]
    27  }