mirror of https://github.com/tgragnato/magnetico
test(opflags): write more test cases for OpFlags.check()
This commit is contained in:
parent
4ebae270c7
commit
c894a547fc
|
|
@ -32,6 +32,11 @@ type OpFlags struct {
|
|||
}
|
||||
|
||||
func (o *OpFlags) check() error {
|
||||
if !o.RunDaemon && !o.RunWeb {
|
||||
o.RunDaemon = true
|
||||
o.RunWeb = true
|
||||
}
|
||||
|
||||
if o.RunWeb {
|
||||
o.Credentials = make(map[string][]byte)
|
||||
if err := o.LoadCred(); err != nil {
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ func TestCheck(t *testing.T) {
|
|||
opFlags: OpFlags{
|
||||
RunDaemon: true,
|
||||
FilterNodesCIDRs: []string{"invalid-cidr"},
|
||||
IndexerAddrs: []string{"0.0.0.0:0"},
|
||||
},
|
||||
expectError: true,
|
||||
},
|
||||
|
|
@ -110,9 +111,29 @@ func TestCheck(t *testing.T) {
|
|||
RunDaemon: true,
|
||||
FilterNodesCIDRs: []string{"192.168.1.0/24"},
|
||||
BootstrappingNodes: []string{"dht.tgragnato.it:80", "dht.tgragnato.it:443", "dht.tgragnato.it:1337", "dht.tgragnato.it:6969", "dht.tgragnato.it:6881", "dht.tgragnato.it:25401"},
|
||||
IndexerAddrs: []string{"0.0.0.0:0"},
|
||||
},
|
||||
expectError: true,
|
||||
},
|
||||
{
|
||||
name: "RunDaemonWithCustomBootstrappingNodesInFilterMode",
|
||||
opFlags: OpFlags{
|
||||
RunDaemon: true,
|
||||
FilterNodesCIDRs: []string{"", "192.168.1.0/24"},
|
||||
BootstrappingNodes: []string{"", "www.tgragnato.it:443"},
|
||||
IndexerAddrs: []string{"0.0.0.0:0"},
|
||||
},
|
||||
expectError: false,
|
||||
},
|
||||
{
|
||||
name: "RunWithBothDaemonAndWebStopped",
|
||||
opFlags: OpFlags{
|
||||
RunDaemon: false,
|
||||
RunWeb: false,
|
||||
IndexerAddrs: []string{"0.0.0.0:0"},
|
||||
},
|
||||
expectError: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
|
|
|||
|
|
@ -18,11 +18,6 @@ func (o *OpFlags) Parse() (err error) {
|
|||
return err
|
||||
}
|
||||
|
||||
if !o.RunDaemon && !o.RunWeb {
|
||||
o.RunDaemon = true
|
||||
o.RunWeb = true
|
||||
}
|
||||
|
||||
return o.check()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue