Maint: do not mock os functions
- Use filepaths with /tmp for tests instead - Only mock functions where filepath can't be specified such as user.Lookup
This commit is contained in:
@@ -3,9 +3,7 @@ package alpine
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/qdm12/golibs/os"
|
||||
"github.com/qdm12/golibs/os/user"
|
||||
"os/user"
|
||||
)
|
||||
|
||||
type Configurator interface {
|
||||
@@ -14,13 +12,17 @@ type Configurator interface {
|
||||
}
|
||||
|
||||
type configurator struct {
|
||||
openFile os.OpenFileFunc
|
||||
osUser user.OSUser
|
||||
alpineReleasePath string
|
||||
passwdPath string
|
||||
lookupID func(uid string) (*user.User, error)
|
||||
lookup func(username string) (*user.User, error)
|
||||
}
|
||||
|
||||
func NewConfigurator(openFile os.OpenFileFunc, osUser user.OSUser) Configurator {
|
||||
func NewConfigurator() Configurator {
|
||||
return &configurator{
|
||||
openFile: openFile,
|
||||
osUser: osUser,
|
||||
alpineReleasePath: "/etc/alpine-release",
|
||||
passwdPath: "/etc/passwd",
|
||||
lookupID: user.LookupId,
|
||||
lookup: user.Lookup,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user