@@ -200,10 +200,15 @@ func TestPromoteWithCacheDeletionFailure(t *testing.T) {
200200
201201func TestGenerateBranchWithSuccess (t * testing.T ) {
202202 repo := mock .New ("/dev" , "master" )
203- GenerateBranchWithSuccess (t , repo )
203+ generateBranchWithSuccess (t , repo )
204204}
205205
206- func GenerateBranchWithSuccess (t * testing.T , repo git.Repo ) {
206+ func TestGenerateBranchForLocalSource (t * testing.T ) {
207+ source := NewLocal ("/path/to/topLevel" )
208+ generateBranchForLocalWithSuccess (t , source )
209+ }
210+
211+ func generateBranchWithSuccess (t * testing.T , repo git.Repo ) {
207212 branch := generateBranch (repo )
208213 nameRegEx := "^([0-9A-Za-z]+)-([0-9a-z]{7})-([0-9A-Za-z]{5})$"
209214 _ , err := regexp .Match (nameRegEx , []byte (branch ))
@@ -212,6 +217,15 @@ func GenerateBranchWithSuccess(t *testing.T, repo git.Repo) {
212217 }
213218}
214219
220+ func generateBranchForLocalWithSuccess (t * testing.T , source git.Source ) {
221+ branch := generateBranchForLocalSource (source )
222+ nameRegEx := "^path-to-topLevel-local-dir-([0-9A-Za-z]{5})$"
223+ _ , err := regexp .Match (nameRegEx , []byte (branch ))
224+ if err != nil {
225+ t .Fatalf ("generated name `%s` for local case %s failed to matching pattern %s" , nameRegEx , source .GetName (), nameRegEx )
226+ }
227+ }
228+
215229type mockSource struct {
216230 files []string
217231 localPath string
@@ -248,6 +262,10 @@ func (s *mockSource) Walk(_ string, cb func(string, string) error) error {
248262 return nil
249263}
250264
265+ func (s * mockSource ) GetName () string {
266+ return "mock-source-name"
267+ }
268+
251269func (s * mockSource ) AddFiles (name string ) {
252270 if s .files == nil {
253271 s .files = []string {}
0 commit comments