github.com/nsqio/nsq@v1.3.0/apps/nsqd/main_test.go (about)

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