pkger/pkging/file_info_test.go

32 lines
615 B
Go
Raw Permalink Normal View History

2019-10-24 23:22:15 +03:00
package pkging_test
import (
"os"
"path/filepath"
"testing"
"time"
2019-11-01 22:53:54 +03:00
"github.com/markbates/pkger/here"
2019-10-24 23:22:15 +03:00
"github.com/markbates/pkger/pkging"
"github.com/stretchr/testify/require"
)
func Test_NewFileInfo(t *testing.T) {
r := require.New(t)
2019-11-01 22:53:54 +03:00
her, err := here.Current()
2019-10-24 23:22:15 +03:00
r.NoError(err)
2019-11-01 22:53:54 +03:00
exp, err := os.Stat(filepath.Join(her.Dir, "go.mod"))
2019-10-24 23:22:15 +03:00
r.NoError(err)
act := pkging.NewFileInfo(exp)
r.Equal(exp.Name(), act.Name())
r.Equal(exp.Size(), act.Size())
r.Equal(exp.Mode(), act.Mode())
r.Equal(exp.IsDir(), act.IsDir())
r.Equal(exp.ModTime().Format(time.RFC3339), act.ModTime().Format(time.RFC3339))
}