-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from sagikazarmark/windows
fix tests on Windows
- Loading branch information
Showing
7 changed files
with
157 additions
and
22 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,32 @@ | ||
//go:build !windows && !plan9 | ||
|
||
package locafero | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/afero" | ||
) | ||
|
||
func ExampleFinder_Find() { | ||
fsys := afero.NewBasePathFs(afero.NewOsFs(), "testdata") | ||
|
||
finder := Finder{ | ||
Paths: []string{ | ||
"/home/user", | ||
"/etc", | ||
}, | ||
Names: []string{"config.*"}, | ||
Type: FileTypeFile, | ||
} | ||
|
||
results, err := finder.Find(fsys) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
fmt.Println("On Unix:", results) | ||
|
||
// Output: | ||
// On Unix: [/home/user/config.yaml /etc/config.yaml] | ||
} |
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,34 @@ | ||
//go:build windows | ||
|
||
package locafero | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/afero" | ||
) | ||
|
||
func ExampleFinder_Find() { | ||
// Use relative paths for Windows, because we do not know the absolute path. | ||
// fsys := afero.NewBasePathFs(afero.NewOsFs(), "testdata") | ||
fsys := afero.NewOsFs() | ||
|
||
finder := Finder{ | ||
Paths: []string{ | ||
"testdata\\home\\user", | ||
"testdata\\etc", | ||
}, | ||
Names: []string{"config.*"}, | ||
Type: FileTypeFile, | ||
} | ||
|
||
results, err := finder.Find(fsys) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
fmt.Println("On Windows:", results) | ||
|
||
// Output: | ||
// On Windows: [testdata\home\user\config.yaml testdata\etc\config.yaml] | ||
} |
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
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,5 @@ | ||
//go:build !windows | ||
|
||
package locafero | ||
|
||
const globMatch = "*?[]\\^" |
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,8 @@ | ||
//go:build windows | ||
|
||
package locafero | ||
|
||
// See [filepath.Match]: | ||
// | ||
// On Windows, escaping is disabled. Instead, '\\' is treated as path separator. | ||
const globMatch = "*?[]^" |