Skip to content

Commit

Permalink
fix unit test for pkg/scaffold/internal (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
howieyuen committed Jun 13, 2022
1 parent 874a13d commit 407d461
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions pkg/scaffold/external_templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"testing"

"bou.ke/monkey"
"github.com/jinzhu/copier"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/gitutil"
"github.com/stretchr/testify/assert"
"gopkg.in/src-d/go-git.v4/plumbing"
Expand Down Expand Up @@ -107,15 +108,12 @@ func TestTemplateRepository_Templates(t *testing.T) {
})

t.Run("read from subdir", func(t *testing.T) {
originalSubDir := localTemplateRepo.SubDirectory
defer func() {
localTemplateRepo.SubDirectory = originalSubDir
}()

localTemplateRepo.SubDirectory = localTemplateRepo.Root
templates, err := localTemplateRepo.Templates()
subRepo := TemplateRepository{}
copier.Copy(&subRepo, &localTemplateRepo)
subRepo.SubDirectory = localTemplateRepo.Root
templates, err := subRepo.Templates()
assert.Nil(t, err)
assert.Equal(t, []Template{localTemplate}, templates)
assert.Contains(t, templates, localTemplate)
})
}

Expand Down Expand Up @@ -266,8 +264,6 @@ func TestCopyTemplateFiles(t *testing.T) {
}
stack2Configs[stack.Name] = configs
}
// project name
projectName := localTemplate.ProjectName
err = CopyTemplateFiles(localRoot, tmp, true, projectName, projectConfigs, stack2Configs)
err = CopyTemplateFiles(localTemplate.Dir, tmp, true, localTemplate.ProjectName, projectConfigs, stack2Configs)
assert.Nil(t, err)
}

0 comments on commit 407d461

Please sign in to comment.