-
Notifications
You must be signed in to change notification settings - Fork 825
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correct CI check for examples and add unit test (#4045)
This fixes a bug within the CI check for unversioned changes to examples, involving an exclude pattern not matching relevant file paths that contain separators.
- Loading branch information
1 parent
af081ce
commit ae07c81
Showing
2 changed files
with
35 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
"testing" | ||
) | ||
|
||
func TestFilenameIsIrrelevant(t *testing.T) { | ||
exampleNames := []string{"inner", "first"} | ||
|
||
irrelevantMap := map[string]bool{ | ||
// in deny-list | ||
"README.md": true, | ||
"cloudbuild.yaml": true, | ||
// in deny-list and inside an example | ||
"examples/inner/outer/EXAMPLE.md": true, | ||
"examples/first/second/third/test.yml": true, | ||
// not in deny list, but outside examples | ||
"outside/test.txt": true, | ||
"1/2/3/4/5.go": true, | ||
// in examples and relevant | ||
"examples/inner/main.go": false, | ||
} | ||
|
||
for filename, expected := range irrelevantMap { | ||
observed := filenameIsIrrelevant(filename, exampleNames) | ||
if observed != expected { | ||
log.Fatalf("%s was expected to be: %t", filename, expected) | ||
} | ||
} | ||
} |