Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

Add error handling for bad directory #247

Merged
merged 3 commits into from
Aug 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions generators/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ func (sg *StaticGenerator) Generate(component *core.Component) (manifest string,

staticPath := path.Join(component.PhysicalPath, component.Path)
staticFiles, err := ioutil.ReadDir(staticPath)
if err != nil {
log.Errorf("error reading from directory %s", staticPath);
return "", err
}

manifests := ""
for _, staticFile := range staticFiles {
Expand Down
20 changes: 20 additions & 0 deletions generators/static_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package generators

import (
"github.com/microsoft/fabrikate/core"
"testing"

"github.com/stretchr/testify/assert"
)

func TestStaticGenerator_Generate(t *testing.T) {
component := core.Component{
Name: "foo",
Path: "",
PhysicalPath: "../testdata/invaliddir",
}

generator := &StaticGenerator{}
_, err := generator.Generate(&component)
assert.NotNil(t, err)
}