github.com/google/osv-scalibr@v0.4.1/extractor/filesystem/language/cpp/conanlock/conanlock_test.go (about) 1 // Copyright 2025 Google LLC 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 conanlock_test 16 17 import ( 18 "testing" 19 20 "github.com/google/osv-scalibr/extractor/filesystem/language/cpp/conanlock" 21 "github.com/google/osv-scalibr/extractor/filesystem/simplefileapi" 22 ) 23 24 func TestExtractor_FileRequired(t *testing.T) { 25 tests := []struct { 26 name string 27 inputPath string 28 want bool 29 }{ 30 { 31 name: "", 32 inputPath: "conan.lock", 33 want: true, 34 }, 35 { 36 name: "", 37 inputPath: "path/to/my/conan.lock", 38 want: true, 39 }, 40 { 41 name: "", 42 inputPath: "path/to/my/conan.lock/file", 43 want: false, 44 }, 45 { 46 name: "", 47 inputPath: "path/to/my/conan.lock.file", 48 want: false, 49 }, 50 { 51 name: "", 52 inputPath: "path.to.my.conan.lock", 53 want: false, 54 }, 55 } 56 for _, tt := range tests { 57 t.Run(tt.name, func(t *testing.T) { 58 e := conanlock.Extractor{} 59 got := e.FileRequired(simplefileapi.New(tt.inputPath, nil)) 60 if got != tt.want { 61 t.Errorf("FileRequired(%s, FileInfo) got = %v, want %v", tt.inputPath, got, tt.want) 62 } 63 }) 64 } 65 }