github.com/solo-io/cue@v0.4.7/internal/filetypes/util_test.go (about) 1 // Copyright 2020 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 // http://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 filetypes 16 17 import "testing" 18 19 func TestIsPackage(t *testing.T) { 20 testCases := []struct { 21 in string 22 out bool 23 }{ 24 {".", true}, 25 {"..", true}, 26 {"../.../foo", true}, 27 {".../foo", true}, 28 {"./:foo", true}, 29 {"foo.bar/foo", true}, 30 31 // Not supported yet, but could be and isn't anything else valid. 32 {":foo", true}, 33 34 {"foo.bar", false}, 35 {"foo:", false}, 36 {"foo:bar:baz", false}, 37 {"-", false}, 38 {"-:foo", false}, 39 } 40 for _, tc := range testCases { 41 t.Run(tc.in, func(t *testing.T) { 42 got := IsPackage(tc.in) 43 if got != tc.out { 44 t.Errorf("got %v; want %v", got, tc.out) 45 } 46 }) 47 } 48 }