main_test.go (nsq-1.2.0) | : | main_test.go (nsq-1.2.1) | ||
---|---|---|---|---|
package main | package main | |||
import ( | import ( | |||
"crypto/tls" | "crypto/tls" | |||
"os" | "os" | |||
"testing" | "testing" | |||
"github.com/BurntSushi/toml" | "github.com/BurntSushi/toml" | |||
"github.com/mreiferson/go-options" | "github.com/mreiferson/go-options" | |||
"github.com/nsqio/nsq/internal/lg" | ||||
"github.com/nsqio/nsq/internal/test" | "github.com/nsqio/nsq/internal/test" | |||
"github.com/nsqio/nsq/nsqd" | "github.com/nsqio/nsq/nsqd" | |||
) | ) | |||
func TestConfigFlagParsing(t *testing.T) { | func TestConfigFlagParsing(t *testing.T) { | |||
opts := nsqd.NewOptions() | opts := nsqd.NewOptions() | |||
opts.Logger = test.NewTestLogger(t) | opts.Logger = test.NewTestLogger(t) | |||
flagSet := nsqdFlagSet(opts) | flagSet := nsqdFlagSet(opts) | |||
flagSet.Parse([]string{}) | flagSet.Parse([]string{}) | |||
var cfg config | var cfg config | |||
f, err := os.Open("../../contrib/nsqd.cfg.example") | f, err := os.Open("../../contrib/nsqd.cfg.example") | |||
if err != nil { | if err != nil { | |||
t.Fatalf("%s", err) | t.Fatalf("%s", err) | |||
} | } | |||
defer f.Close() | ||||
toml.DecodeReader(f, &cfg) | toml.DecodeReader(f, &cfg) | |||
cfg["log_level"] = "debug" | ||||
cfg.Validate() | cfg.Validate() | |||
options.Resolve(opts, flagSet, cfg) | options.Resolve(opts, flagSet, cfg) | |||
nsqd.New(opts) | nsqd.New(opts) | |||
if opts.TLSMinVersion != tls.VersionTLS10 { | if opts.TLSMinVersion != tls.VersionTLS10 { | |||
t.Errorf("min %#v not expected %#v", opts.TLSMinVersion, tls.Vers ionTLS10) | t.Errorf("min %#v not expected %#v", opts.TLSMinVersion, tls.Vers ionTLS10) | |||
} | } | |||
if opts.LogLevel != lg.DEBUG { | ||||
t.Fatalf("log level: want debug, got %s", opts.LogLevel.String()) | ||||
} | ||||
} | } | |||
End of changes. 4 change blocks. | ||||
0 lines changed or deleted | 6 lines changed or added |