main_test.go 878 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package main
  2. import (
  3. "crypto/tls"
  4. "os"
  5. "testing"
  6. "github.com/BurntSushi/toml"
  7. "github.com/mreiferson/go-options"
  8. "github.com/nsqio/nsq/internal/lg"
  9. "github.com/nsqio/nsq/internal/test"
  10. "github.com/nsqio/nsq/nsqd"
  11. )
  12. func TestConfigFlagParsing(t *testing.T) {
  13. opts := nsqd.NewOptions()
  14. opts.Logger = test.NewTestLogger(t)
  15. flagSet := nsqdFlagSet(opts)
  16. flagSet.Parse([]string{})
  17. var cfg config
  18. f, err := os.Open("../../contrib/nsqd.cfg.example")
  19. if err != nil {
  20. t.Fatalf("%s", err)
  21. }
  22. defer f.Close()
  23. toml.DecodeReader(f, &cfg)
  24. cfg["log_level"] = "debug"
  25. cfg.Validate()
  26. options.Resolve(opts, flagSet, cfg)
  27. nsqd.New(opts)
  28. if opts.TLSMinVersion != tls.VersionTLS10 {
  29. t.Errorf("min %#v not expected %#v", opts.TLSMinVersion, tls.VersionTLS10)
  30. }
  31. if opts.LogLevel != lg.DEBUG {
  32. t.Fatalf("log level: want debug, got %s", opts.LogLevel.String())
  33. }
  34. }