File: glob_test.go

package info (click to toggle)
golang-gopkg-src-d-go-billy.v4 4.3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 280 kB
  • sloc: makefile: 21
file content (34 lines) | stat: -rw-r--r-- 662 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package util_test

import (
	"path/filepath"
	"sort"
	"testing"

	. "gopkg.in/check.v1"
	"gopkg.in/src-d/go-billy.v4/memfs"
	"gopkg.in/src-d/go-billy.v4/util"
)

func Test(t *testing.T) { TestingT(t) }

var _ = Suite(&UtilSuite{})

type UtilSuite struct{}

func (s *UtilSuite) TestCreate(c *C) {
	fs := memfs.New()
	util.WriteFile(fs, "foo/qux", nil, 0644)
	util.WriteFile(fs, "foo/bar", nil, 0644)
	util.WriteFile(fs, "foo/baz/foo", nil, 0644)

	names, err := util.Glob(fs, "*/b*")
	c.Assert(err, IsNil)
	c.Assert(names, HasLen, 2)
	sort.Strings(names)
	c.Assert(names, DeepEquals, []string{
		filepath.Join("foo", "bar"),
		filepath.Join("foo", "baz"),
	})

}