mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-25 06:25:44 +03:00
9bac4b3db2
Merge in DNS/adguard-home from 3845-hosts-fatality to master Updates #3845. Squashed commit of the following: commit 1447efcc4066e0226feaebde01fcc632cb7b7432 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Wed Nov 17 17:14:35 2021 +0300 home: imp readability commit e934499072e983e1111b6c976eb93e1d6017981b Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Wed Nov 17 13:35:10 2021 +0300 aghnet: imp more commit ed9995ee52bd9ec3fa130f3f56989619184a6669 Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Wed Nov 17 13:05:56 2021 +0300 all: imp docs, code commit 7b0718a1a4a58a4fd5f1ba24c33792b0610c334f Author: Eugene Burkov <E.Burkov@AdGuard.COM> Date: Tue Nov 16 20:32:24 2021 +0300 all: reduce hosts container fatality
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
package aghtest
|
|
|
|
import "io/fs"
|
|
|
|
// type check
|
|
var _ fs.FS = &FS{}
|
|
|
|
// FS is a mock fs.FS implementation to use in tests.
|
|
type FS struct {
|
|
OnOpen func(name string) (fs.File, error)
|
|
}
|
|
|
|
// Open implements the fs.FS interface for *FS.
|
|
func (fsys *FS) Open(name string) (fs.File, error) {
|
|
return fsys.OnOpen(name)
|
|
}
|
|
|
|
// type check
|
|
var _ fs.StatFS = &StatFS{}
|
|
|
|
// StatFS is a mock fs.StatFS implementation to use in tests.
|
|
type StatFS struct {
|
|
// FS is embedded here to avoid implementing all it's methods.
|
|
FS
|
|
OnStat func(name string) (fs.FileInfo, error)
|
|
}
|
|
|
|
// Stat implements the fs.StatFS interface for *StatFS.
|
|
func (fsys *StatFS) Stat(name string) (fs.FileInfo, error) {
|
|
return fsys.OnStat(name)
|
|
}
|
|
|
|
// type check
|
|
var _ fs.GlobFS = &GlobFS{}
|
|
|
|
// GlobFS is a mock fs.GlobFS implementation to use in tests.
|
|
type GlobFS struct {
|
|
// FS is embedded here to avoid implementing all it's methods.
|
|
FS
|
|
OnGlob func(pattern string) ([]string, error)
|
|
}
|
|
|
|
// Glob implements the fs.GlobFS interface for *GlobFS.
|
|
func (fsys *GlobFS) Glob(pattern string) ([]string, error) {
|
|
return fsys.OnGlob(pattern)
|
|
}
|