Skip to content

Commit 5332f2d

Browse files
authored
Merge pull request #83 from asalkeld/default-runtime-config
fix: Runtime config when none exists
2 parents 6f43ada + 8faee23 commit 5332f2d

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

pkg/stack/options_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package stack
1818

1919
import (
2020
"reflect"
21+
"sort"
2122
"testing"
2223

2324
"github.com/google/go-cmp/cmp"
@@ -135,3 +136,23 @@ func TestFromOptionsMinimal(t *testing.T) {
135136
})
136137
}
137138
}
139+
140+
func TestEnsureRuntimeDefaults(t *testing.T) {
141+
want := true
142+
143+
if got := EnsureRuntimeDefaults(); got != want {
144+
t.Errorf("EnsureRuntimeDefaults() = %v, want %v", got, want)
145+
}
146+
expectGlobs := []string{"functions/*/*.go", "functions/*.ts"}
147+
sort.SliceStable(expectGlobs, func(i, j int) bool {
148+
return expectGlobs[i] < expectGlobs[j]
149+
})
150+
globs := defaultGlobsFromConfig()
151+
sort.SliceStable(globs, func(i, j int) bool {
152+
return globs[i] < globs[j]
153+
})
154+
155+
if !cmp.Equal(expectGlobs, globs) {
156+
t.Error(cmp.Diff(expectGlobs, globs))
157+
}
158+
}

pkg/utils/cast.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ func ToStringMapStringMapStringE(i interface{}) (map[string]map[string]interface
3737
}
3838
}
3939
return m, nil
40+
case nil:
41+
return map[string]map[string]interface{}{}, nil
4042
default:
4143
return nil, fmt.Errorf("unable to cast %#v of type %T to map[string]map[string]interface{}", i, i)
4244
}

0 commit comments

Comments
 (0)