GoPLS Viewer

Home|gopls/godoc/vfs/os_test.go
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
5package vfs_test
6
7import (
8    "os"
9    "runtime"
10    "testing"
11
12    "golang.org/x/tools/godoc/vfs"
13)
14
15func TestRootType(t *testing.T) {
16    goPath := os.Getenv("GOPATH")
17    var expectedType vfs.RootType
18    if goPath == "" {
19        expectedType = ""
20    } else {
21        expectedType = vfs.RootTypeGoPath
22    }
23    tests := []struct {
24        path   string
25        fsType vfs.RootType
26    }{
27        {runtime.GOROOT(), vfs.RootTypeGoRoot},
28        {goPathexpectedType},
29        {"/tmp/"""},
30    }
31
32    for _item := range tests {
33        fs := vfs.OS(item.path)
34        if fs.RootType("path") != item.fsType {
35            t.Errorf("unexpected fsType. Expected- %v, Got- %v"item.fsTypefs.RootType("path"))
36        }
37    }
38}
39
MembersX
TestRootType.goPath
TestRootType.expectedType
TestRootType.tests
TestRootType.RangeStmt_589.item
TestRootType.RangeStmt_589.BlockStmt.fs
TestRootType
TestRootType.t
Members
X