github.com/hdt3213/godis@v1.2.9/config/config_test.go (about)

     1  package config
     2  
     3  import (
     4  	"strings"
     5  	"testing"
     6  )
     7  
     8  func TestParse(t *testing.T) {
     9  	src := "bind 0.0.0.0\n" +
    10  		"port 6399\n" +
    11  		"appendonly yes\n" +
    12  		"peers a,b"
    13  	p := parse(strings.NewReader(src))
    14  	if p == nil {
    15  		t.Error("cannot get result")
    16  		return
    17  	}
    18  	if p.Bind != "0.0.0.0" {
    19  		t.Error("string parse failed")
    20  	}
    21  	if p.Port != 6399 {
    22  		t.Error("int parse failed")
    23  	}
    24  	if !p.AppendOnly {
    25  		t.Error("bool parse failed")
    26  	}
    27  	if len(p.Peers) != 2 || p.Peers[0] != "a" || p.Peers[1] != "b" {
    28  		t.Error("list parse failed")
    29  	}
    30  }