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

Commit

Permalink
Add error handling for bad directory (#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham1172 authored and timfpark committed Aug 23, 2019
1 parent a2a946d commit 56d5968
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
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)
}

0 comments on commit 56d5968

Please sign in to comment.