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:
Matej Vasek 2022-04-06 23:59:44 +02:00 committed by GitHub
parent 1ee9fa163b
commit 94dd53d009
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 6 deletions

View File

@ -9,13 +9,13 @@ import (
"io/ioutil"
"os"
"path/filepath"
"reflect"
"runtime"
"sort"
"testing"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/google/go-cmp/cmp"
)
func TestFileSystems(t *testing.T) {
@ -79,11 +79,8 @@ func TestFileSystems(t *testing.T) {
sort.Strings(embeddedFiles)
sort.Strings(localFiles)
if !reflect.DeepEqual(embeddedFiles, localFiles) {
t.Log("embedded files: ", embeddedFiles)
t.Log("local files: ", localFiles)
t.Error("content of embedded files doesn't match the filesystem")
return
if diff := cmp.Diff(localFiles, embeddedFiles); diff != "" {
t.Error("filesystem content missmatch (-want, +got):", diff)
}
err = fs.WalkDir(templatesFS, ".", func(path string, d fs.DirEntry, err error) error {

View File

@ -71,6 +71,7 @@ func main() {
if err != nil {
return err
}
defer f.Close()
_, err = io.CopyBuffer(w, f, buff)
if err != nil {