mirror of https://github.com/libp2p/go-libp2p.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
399 B
24 lines
399 B
6 years ago
|
package config
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestNilOption(t *testing.T) {
|
||
|
var cfg Config
|
||
|
optsRun := 0
|
||
|
opt := func(c *Config) error {
|
||
|
optsRun++
|
||
|
return nil
|
||
|
}
|
||
|
if err := cfg.Apply(nil); err != nil {
|
||
|
t.Fatal(err)
|
||
|
}
|
||
|
if err := cfg.Apply(opt, nil, nil, opt, opt, nil); err != nil {
|
||
|
t.Fatal(err)
|
||
|
}
|
||
|
if optsRun != 3 {
|
||
|
t.Fatalf("expected to have handled 3 options, handled %d", optsRun)
|
||
|
}
|
||
|
}
|