1 | // Copyright 2018 The Go Authors. All rights reserved. |
---|---|
2 | // Use of this source code is governed by a BSD-style |
3 | // license that can be found in the LICENSE file. |
4 | |
5 | package gatefs_test |
6 | |
7 | import ( |
8 | "os" |
9 | "runtime" |
10 | "testing" |
11 | |
12 | "golang.org/x/tools/godoc/vfs" |
13 | "golang.org/x/tools/godoc/vfs/gatefs" |
14 | ) |
15 | |
16 | func TestRootType(t *testing.T) { |
17 | goPath := os.Getenv("GOPATH") |
18 | var expectedType vfs.RootType |
19 | if goPath == "" { |
20 | expectedType = "" |
21 | } else { |
22 | expectedType = vfs.RootTypeGoPath |
23 | } |
24 | tests := []struct { |
25 | path string |
26 | fsType vfs.RootType |
27 | }{ |
28 | {runtime.GOROOT(), vfs.RootTypeGoRoot}, |
29 | {goPath, expectedType}, |
30 | {"/tmp/", ""}, |
31 | } |
32 | |
33 | for _, item := range tests { |
34 | fs := gatefs.New(vfs.OS(item.path), make(chan bool, 1)) |
35 | if fs.RootType("path") != item.fsType { |
36 | t.Errorf("unexpected fsType. Expected- %v, Got- %v", item.fsType, fs.RootType("path")) |
37 | } |
38 | } |
39 | } |
40 |
Members