Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / tools@v0.0.0-20201028153306-37f0764111ff / internal / lsp / cache / view_test.go
1 // Copyright 2020 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 package cache
5
6 import (
7         "io/ioutil"
8         "os"
9         "path/filepath"
10         "testing"
11 )
12
13 func TestCaseInsensitiveFilesystem(t *testing.T) {
14         base, err := ioutil.TempDir("", t.Name())
15         if err != nil {
16                 t.Fatal(err)
17         }
18
19         inner := filepath.Join(base, "a/B/c/DEFgh")
20         if err := os.MkdirAll(inner, 0777); err != nil {
21                 t.Fatal(err)
22         }
23         file := filepath.Join(inner, "f.go")
24         if err := ioutil.WriteFile(file, []byte("hi"), 0777); err != nil {
25                 t.Fatal(err)
26         }
27         if _, err := os.Stat(filepath.Join(inner, "F.go")); err != nil {
28                 t.Skip("filesystem is case-sensitive")
29         }
30
31         tests := []struct {
32                 path string
33                 err  bool
34         }{
35                 {file, false},
36                 {filepath.Join(inner, "F.go"), true},
37                 {filepath.Join(base, "a/b/c/defgh/f.go"), true},
38         }
39         for _, tt := range tests {
40                 err := checkPathCase(tt.path)
41                 if err != nil != tt.err {
42                         t.Errorf("checkPathCase(%q) = %v, wanted error: %v", tt.path, err, tt.err)
43                 }
44         }
45 }