mirror of https://github.com/knative/func.git
Template generation improvements (#949)
* Improve test error output Signed-off-by: Matej Vasek <mvasek@redhat.com> * Template ZIP generator close file after use Signed-off-by: Matej Vasek <mvasek@redhat.com>
This commit is contained in:
parent
1ee9fa163b
commit
94dd53d009
|
@ -9,13 +9,13 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"sort"
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/go-git/go-git/v5"
|
"github.com/go-git/go-git/v5"
|
||||||
"github.com/go-git/go-git/v5/plumbing/object"
|
"github.com/go-git/go-git/v5/plumbing/object"
|
||||||
|
"github.com/google/go-cmp/cmp"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestFileSystems(t *testing.T) {
|
func TestFileSystems(t *testing.T) {
|
||||||
|
@ -79,11 +79,8 @@ func TestFileSystems(t *testing.T) {
|
||||||
sort.Strings(embeddedFiles)
|
sort.Strings(embeddedFiles)
|
||||||
sort.Strings(localFiles)
|
sort.Strings(localFiles)
|
||||||
|
|
||||||
if !reflect.DeepEqual(embeddedFiles, localFiles) {
|
if diff := cmp.Diff(localFiles, embeddedFiles); diff != "" {
|
||||||
t.Log("embedded files: ", embeddedFiles)
|
t.Error("filesystem content missmatch (-want, +got):", diff)
|
||||||
t.Log("local files: ", localFiles)
|
|
||||||
t.Error("content of embedded files doesn't match the filesystem")
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = fs.WalkDir(templatesFS, ".", func(path string, d fs.DirEntry, err error) error {
|
err = fs.WalkDir(templatesFS, ".", func(path string, d fs.DirEntry, err error) error {
|
||||||
|
|
|
@ -71,6 +71,7 @@ func main() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
_, err = io.CopyBuffer(w, f, buff)
|
_, err = io.CopyBuffer(w, f, buff)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue