Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
omryMen committed Feb 13, 2024
1 parent 20f6e95 commit a3f8a32
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/codeowners/codeowners_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,20 +266,22 @@ func cwd() string {
return cwd
}

func ExampleFromFile() {
func testDir() string {
tpath, _ := filepath.Abs(filepath.Dir(filepath.Dir(cwd())))
tpath += "/tests"
c, _ := FromFile(tpath)
return tpath
}

func ExampleFromFile() {
c, _ := FromFile(testDir())
fmt.Println(c.Patterns[0])
// Output:
// * bridgecrewio
}

func ExampleFromFileWithFS() {
tpath, _ := filepath.Abs(filepath.Dir(filepath.Dir(cwd())))
tpath += "/tests"
// open filesystem rooted at current working directory
fsys := os.DirFS(tpath)
fsys := os.DirFS(testDir())

c, _ := FromFileWithFS(fsys, ".")
fmt.Println(c.Patterns[0])
Expand All @@ -296,11 +298,11 @@ func ExampleFromReader() {
}

func ExampleCodeowners_Owners() {
c, _ := FromFile(cwd())
c, _ := FromFile(testDir())
owners := c.Owners("README.md")
for i, o := range owners {
fmt.Printf("Owner #%d is %s\n", i, o)
}
// Output:
// Owner #0 is @hairyhenderson
// Owner #0 is bridgecrewio
}

0 comments on commit a3f8a32

Please sign in to comment.