Add tests for influx consistency level parsing

pull/3947/head
Jason Wilder 2015-09-02 09:11:47 -06:00
parent 1464ee5397
commit 1d4ee6c3fa
3 changed files with 28 additions and 3 deletions

View File

@ -234,8 +234,8 @@ func (w *PointsWriter) writeToShard(shard *meta.ShardInfo, database, retentionPo
// response channel for each shard writer go routine
type AsyncWriteResult struct {
Owner meta.ShardOwner
Err error
Owner meta.ShardOwner
Err error
}
ch := make(chan *AsyncWriteResult, len(shard.Owners))

View File

@ -53,7 +53,7 @@ type CommandLine struct {
Execute string
ShowVersion bool
Import bool
PPS int // Controls how many points per second the import will allow via throttling
PPS int // Controls how many points per second the import will allow via throttling
Path string
Compressed bool
}

View File

@ -91,6 +91,31 @@ func TestParseCommand_Use(t *testing.T) {
}
}
func TestParseCommand_Consistency(t *testing.T) {
t.Parallel()
c := main.CommandLine{}
tests := []struct {
cmd string
}{
{cmd: "consistency one"},
{cmd: " consistency one"},
{cmd: "consistency one "},
{cmd: "consistency one;"},
{cmd: "consistency one; "},
{cmd: "Consistency one"},
}
for _, test := range tests {
if !c.ParseCommand(test.cmd) {
t.Fatalf(`Command "consistency" failed for %q.`, test.cmd)
}
if c.WriteConsistency != "one" {
t.Fatalf(`Command "consistency" changed consistency to %q. Expected one`, c.WriteConsistency)
}
}
}
func TestParseCommand_Insert(t *testing.T) {
t.Parallel()
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {