cuelang.org/go@v0.10.1/cue/interpreter/embed/embed_test.go (about)

     1  // Copyright 2024 CUE Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     https://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package embed
    16  
    17  import "testing"
    18  
    19  func TestIsHidden(t *testing.T) {
    20  	// These test cases are the same for both Unix and Windows.
    21  	testCases := []struct {
    22  		path string
    23  		want bool
    24  	}{{
    25  		path: "",
    26  		want: false,
    27  	}, {
    28  		path: "foo",
    29  		want: false,
    30  	}, {
    31  		path: ".foo",
    32  		want: true,
    33  	}, {
    34  		path: "foo/bar",
    35  		want: false,
    36  	}, {
    37  		path: "foo/.bar",
    38  		want: true,
    39  	}, {
    40  		path: ".foo/bar",
    41  		want: true,
    42  	}, {
    43  		path: "x/.foo/bar",
    44  		want: true,
    45  	}}
    46  	c := &compiler{dir: "/tmp"}
    47  	for _, tc := range testCases {
    48  		t.Run(tc.path, func(t *testing.T) {
    49  			got := c.isHidden(tc.path)
    50  			if got != tc.want {
    51  				t.Errorf("isHidden(%q) = %t; want %t", tc.path, got, tc.want)
    52  			}
    53  		})
    54  	}
    55  }