forked from influxdata/telegraf
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Fix linter findings for Windows (part4) (influxdata#13246)
Co-authored-by: Pawel Zak <Pawel Zak> Co-authored-by: pzak <pzak>
- Loading branch information
Showing
24 changed files
with
272 additions
and
239 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
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
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,52 @@ | ||
//go:build !windows | ||
|
||
// TODO: These types are not used in Windows tests because they are disabled for Windows. | ||
// They can be moved to filesystem_helpers.go when following bug is fixed: | ||
// https://github.com/influxdata/telegraf/issues/6248 | ||
|
||
package filecount | ||
|
||
import ( | ||
"errors" | ||
"os" | ||
"time" | ||
) | ||
|
||
/* | ||
The following are for mocking the filesystem - this allows us to mock Stat() files. This means that we can set file attributes, and know that they | ||
will be the same regardless of the platform sitting underneath our tests (directory sizes vary see https://github.com/influxdata/telegraf/issues/6011) | ||
NOTE: still need the on-disk file structure to mirror this because the 3rd party library ("github.com/karrick/godirwalk") uses its own | ||
walk functions, that we cannot mock from here. | ||
*/ | ||
|
||
type fakeFileSystem struct { | ||
files map[string]fakeFileInfo | ||
} | ||
|
||
type fakeFileInfo struct { | ||
name string | ||
size int64 | ||
filemode uint32 | ||
modtime time.Time | ||
isdir bool | ||
sys interface{} | ||
} | ||
|
||
func (f fakeFileInfo) Name() string { return f.name } | ||
func (f fakeFileInfo) Size() int64 { return f.size } | ||
func (f fakeFileInfo) Mode() os.FileMode { return os.FileMode(f.filemode) } | ||
func (f fakeFileInfo) ModTime() time.Time { return f.modtime } | ||
func (f fakeFileInfo) IsDir() bool { return f.isdir } | ||
func (f fakeFileInfo) Sys() interface{} { return f.sys } | ||
|
||
func (f fakeFileSystem) Open(name string) (file, error) { | ||
return nil, &os.PathError{Op: "Open", Path: name, Err: errors.New("not implemented by fake filesystem")} | ||
} | ||
|
||
func (f fakeFileSystem) Stat(name string) (os.FileInfo, error) { | ||
if fakeInfo, found := f.files[name]; found { | ||
return fakeInfo, nil | ||
} | ||
return nil, &os.PathError{Op: "Stat", Path: name, Err: errors.New("no such file or directory")} | ||
} |
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
Oops, something went wrong.