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

Commit

Permalink
fixes tests on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
markbates committed Sep 22, 2018
1 parent 5ac31f8 commit d60133c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
3 changes: 3 additions & 0 deletions v2/box.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ func (b Box) List() []string {
var keys []string

b.Walk(func(path string, info File) error {
if info == nil {
return nil
}
finfo, _ := info.FileInfo()
if !finfo.IsDir() {
keys = append(keys, finfo.Name())
Expand Down
3 changes: 1 addition & 2 deletions v2/box_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,9 @@ func Test_Box_MustBytes_Miss(t *testing.T) {
r := require.New(t)

box := NewBox("./_fixtures/templates")

s, err := box.MustBytes("foo.txt")
r.NoError(err)
r.Equal("FOO!!!\n", string(s))
r.Equal("FOO!!!", strings.TrimSpace(string(s)))

s, err = box.MustBytes("idontexist")
r.Error(err)
Expand Down
4 changes: 3 additions & 1 deletion v2/jam/parser/prospect.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"os"
"path/filepath"
"strings"

"github.com/gobuffalo/packr/v2/file/resolver"
)

var DefaultIgnoredFolders = []string{"vendor", ".git", "node_modules", ".idea", "_fixtures"}
Expand Down Expand Up @@ -34,7 +36,7 @@ func IsProspect(path string, ignore ...string) bool {
ignore[i] = strings.TrimSpace(strings.ToLower(x))
}

parts := strings.Split(path, string(filepath.Separator))
parts := strings.Split(resolver.OsPath(path), string(filepath.Separator))
if len(parts) == 0 {
return false
}
Expand Down
9 changes: 5 additions & 4 deletions v2/jam/store/disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package store

import (
"path/filepath"
"strings"
"testing"

"github.com/gobuffalo/packr/v2"
Expand Down Expand Up @@ -39,11 +40,11 @@ func Test_Disk_Files(t *testing.T) {

f := files[0]
r.Equal("aretha.txt", filepath.Base(f.Name()))
r.Equal("RESPECT!\n", f.String())
r.Equal("RESPECT!", strings.TrimSpace(f.String()))

f = files[1]
r.Equal("think.txt", filepath.Base(f.Name()))
r.Equal("THINK!\n", f.String())
r.Equal("THINK!", strings.TrimSpace(f.String()))
}

func Test_Disk_Pack(t *testing.T) {
Expand Down Expand Up @@ -76,11 +77,11 @@ func Test_Disk_Packed_Test(t *testing.T) {

s, err := b.MustString("parents/homer.txt")
r.NoError(err)
r.Equal("HOMER Simpson\n", s)
r.Equal("HOMER Simpson", strings.TrimSpace(s))

s, err = b.MustString("parents/marge.txt")
r.NoError(err)
r.Equal("MARGE Simpson\n", s)
r.Equal("MARGE Simpson", strings.TrimSpace(s))

_, err = b.MustString("idontexist")
r.Error(err)
Expand Down
3 changes: 1 addition & 2 deletions v2/walk.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ func (b *Box) Walk(wf WalkFunc) error {
sort.Strings(keys)

for _, k := range keys {
k = resolver.OsPath(k)
if err := wf(k, m[k]); err != nil {
if err := wf(resolver.OsPath(k), m[k]); err != nil {
return errors.WithStack(err)
}
}
Expand Down

0 comments on commit d60133c

Please sign in to comment.