feat(geoip, info): write comprehensive unit tests
This commit is contained in:
parent
fa803300bb
commit
7eedf4d947
6 changed files with 415 additions and 41 deletions
|
|
@ -4,24 +4,33 @@ import (
|
|||
"github.com/alecthomas/kingpin"
|
||||
"github.com/apex/log"
|
||||
"github.com/ooni/probe-cli/internal/cli/root"
|
||||
"github.com/ooni/probe-cli/internal/ooni"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := root.Command("info", "Display information about OONI Probe")
|
||||
|
||||
cmd.Action(func(_ *kingpin.ParseContext) error {
|
||||
probeCLI, err := root.Init()
|
||||
if err != nil {
|
||||
log.Errorf("%s", err)
|
||||
return err
|
||||
}
|
||||
log.WithFields(log.Fields{
|
||||
"path": probeCLI.Home(),
|
||||
}).Info("Home")
|
||||
log.WithFields(log.Fields{
|
||||
"path": probeCLI.TempDir(),
|
||||
}).Info("TempDir")
|
||||
|
||||
return nil
|
||||
return doinfo(defaultconfig)
|
||||
})
|
||||
}
|
||||
|
||||
type doinfoconfig struct {
|
||||
Logger log.Interface
|
||||
NewProbeCLI func() (ooni.ProbeCLI, error)
|
||||
}
|
||||
|
||||
var defaultconfig = doinfoconfig{
|
||||
Logger: log.Log,
|
||||
NewProbeCLI: root.NewProbeCLI,
|
||||
}
|
||||
|
||||
func doinfo(config doinfoconfig) error {
|
||||
probeCLI, err := config.NewProbeCLI()
|
||||
if err != nil {
|
||||
config.Logger.Errorf("%s", err)
|
||||
return err
|
||||
}
|
||||
config.Logger.WithFields(log.Fields{"path": probeCLI.Home()}).Info("Home")
|
||||
config.Logger.WithFields(log.Fields{"path": probeCLI.TempDir()}).Info("TempDir")
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue