2019-09-03 19:02:55 +03:00
|
|
|
package pkgtest
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/markbates/pkger/pkging/pkgutil"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s Suite) Test_File_Info(t *testing.T) {
|
|
|
|
r := require.New(t)
|
2019-09-12 04:29:39 +03:00
|
|
|
|
|
|
|
pkg, err := s.Make()
|
|
|
|
r.NoError(err)
|
|
|
|
|
|
|
|
cur, err := pkg.Current()
|
2019-09-03 19:02:55 +03:00
|
|
|
r.NoError(err)
|
|
|
|
|
|
|
|
ip := cur.ImportPath
|
|
|
|
table := []struct {
|
|
|
|
in string
|
|
|
|
}{
|
|
|
|
{in: mould},
|
|
|
|
{in: ":" + mould},
|
|
|
|
{in: ip + ":" + mould},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, tt := range table {
|
2019-09-03 23:45:32 +03:00
|
|
|
s.Run(t, tt.in, func(st *testing.T) {
|
2019-09-03 19:02:55 +03:00
|
|
|
r := require.New(st)
|
|
|
|
|
2019-09-12 04:29:39 +03:00
|
|
|
r.NoError(pkg.RemoveAll(mould))
|
|
|
|
r.NoError(pkg.MkdirAll(filepath.Dir(tt.in), 0755))
|
|
|
|
err := pkgutil.WriteFile(pkg, tt.in, []byte(mould), 0644)
|
2019-09-03 19:02:55 +03:00
|
|
|
r.NoError(err)
|
|
|
|
|
2019-09-12 04:29:39 +03:00
|
|
|
f, err := pkg.Open(tt.in)
|
2019-09-03 19:02:55 +03:00
|
|
|
r.NoError(err)
|
2019-09-03 19:41:21 +03:00
|
|
|
r.Equal(mould, f.Name())
|
2019-09-03 19:02:55 +03:00
|
|
|
r.Equal(cur.ImportPath, f.Info().ImportPath)
|
2019-09-03 19:41:21 +03:00
|
|
|
r.NoError(f.Close())
|
2019-09-03 19:02:55 +03:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-03 22:18:31 +03:00
|
|
|
// func (s Suite) Test_File_Read(t *testing.T) {
|
|
|
|
// panic("not implemented")
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// func (s Suite) Test_File_Readdir(t *testing.T) {
|
|
|
|
// panic("not implemented")
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// func (s Suite) Test_File_Seek(t *testing.T) {
|
|
|
|
// panic("not implemented")
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// func (s Suite) Test_File_Stat(t *testing.T) {
|
|
|
|
// panic("not implemented")
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// func (s Suite) Test_File_Write(t *testing.T) {
|
|
|
|
// panic("not implemented")
|
|
|
|
// }
|