Skip to content

Commit

Permalink
parsing output/input directory from module
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcheung committed Jun 11, 2020
1 parent dbfbb43 commit 6dc7a74
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions internal/config/moduleconfig/module_config.go
Expand Up @@ -28,8 +28,8 @@ type Parameter struct {
type TemplateConfig struct {
StrictMode bool
Delimiters []string
InputDir string
OutputDir string
InputDir string `yaml:"inputDir"`
OutputDir string `yaml:"outputDir"`
}

func LoadModuleConfig(filePath string) (ModuleConfig, error) {
Expand Down
9 changes: 8 additions & 1 deletion internal/module/module_test.go
Expand Up @@ -27,7 +27,7 @@ func TestGetSourceDir(t *testing.T) {
}
}

func TestNewTemplateModule(t *testing.T) {
func TestParseModuleConfig(t *testing.T) {
testModuleSource := "../../tests/test_data/modules/ci"
var mod moduleconfig.ModuleConfig

Expand All @@ -46,6 +46,13 @@ func TestNewTemplateModule(t *testing.T) {
assert.Equal(t, "CI Platform", param.Label)
})

t.Run("TemplateConfig is unmarshaled", func(t *testing.T) {
mod, _ = module.ParseModuleConfig(testModuleSource)
assert.Equal(t, ".circleci", mod.TemplateConfig.OutputDir)
assert.Equal(t, "templates", mod.TemplateConfig.InputDir)
assert.Equal(t, []string{"<%", "%>"}, mod.TemplateConfig.Delimiters)
})

}

func findParameter(params []moduleconfig.Parameter, field string) (moduleconfig.Parameter, error) {
Expand Down
3 changes: 2 additions & 1 deletion tests/test_data/modules/ci/zero-module.yml
Expand Up @@ -10,7 +10,8 @@ template:
delimiters:
- "<%"
- "%>"
output: "github/test"
inputDir: 'templates'
outputDir: ".circleci"

# required context parameters: will throw a warning message at the end if any of the context parameters are not present
# contextRequired:
Expand Down

0 comments on commit 6dc7a74

Please sign in to comment.