Exemplo n.º 1
0
func TestGoRun(t *testing.T) {
	e := newTestGo()
	s, _, _ := ponyExpress.NewTestStoreFront()
	e.Run(s)
	if e == nil {
		t.Fail()
	}
}
Exemplo n.º 2
0
func TestGoReport(t *testing.T) {
	e := newTestGo()
	s, _, _ := ponyExpress.NewTestStoreFront()
	report := e.Report(s)
	if report != "Go " {
		t.Errorf("Expected: %v\nGot: %v\n", "Go ", report)
	}
}
Exemplo n.º 3
0
func TestExecReport(t *testing.T) {
	e := newTestExec()
	s, _, _ := ponyExpress.NewTestStoreFront()
	rep := e.Report(s)
	if rep != "" {
		t.Fail()
	}
}
Exemplo n.º 4
0
func TestWaitReport(t *testing.T) {
	e := newTestWait()
	s, _, _ := ponyExpress.NewTestStoreFront()
	rpt := e.Report(s)
	if !strings.Contains(rpt, "WAIT") {
		t.Fail()
	}
}
Exemplo n.º 5
0
func TestSetReport(t *testing.T) {
	set := newTestSet("this", "that")
	s, _, _ := ponyExpress.NewTestStoreFront()
	rpt := set.Report(s)
	expected := fmt.Sprintf("SET %v = '%v'", set.Var, set.Value)
	if rpt != expected {
		t.Errorf("expected: %v\ngot: %v\n", expected, rpt)
	}
}
Exemplo n.º 6
0
func TestQueryRun(t *testing.T) {
	i := newTestQuery()
	s, packageCh, _ := ponyExpress.NewTestStoreFront()
	// Listen to the other side of the directiveCh
	go func() {
		for pkg := range packageCh {
			if i.TemplateString != string(pkg.Body) {
				t.Fail()
			}
			pkg.Tracer.Done()
		}
	}()
	i.Run(s)
}
Exemplo n.º 7
0
func TestInfluxQlRun(t *testing.T) {
	e := newTestInfluxQl()
	s, packageCh, _ := ponyExpress.NewTestStoreFront()
	go func() {
		for pkg := range packageCh {
			if pkg.T != ponyExpress.Query {
				t.Errorf("Expected package to be Query\nGot: %v", pkg.T)
			}
			if string(pkg.Body) != e.Query {
				t.Errorf("Expected query: %v\nGot: %v", e.Query, string(pkg.Body))
			}
			if pkg.StatementID != e.StatementID {
				t.Errorf("Expected statementID: %v\nGot: %v", e.StatementID, pkg.StatementID)
			}
			pkg.Tracer.Done()
		}
	}()
	e.Run(s)
}
Exemplo n.º 8
0
func TestInsertRun(t *testing.T) {
	i := newTestInsert()
	s, packageCh, _ := ponyExpress.NewTestStoreFront()
	// Listen to the other side of the directiveCh
	go func() {
		for pkg := range packageCh {
			countPoints := i.Timestamp.Count
			batchSize := s.BatchSize
			got := len(strings.Split(string(pkg.Body), "\n"))
			switch got {
			case countPoints % batchSize:
			case batchSize:
			default:
				t.Errorf("countPoints: %v\nbatchSize: %v\ngot: %v\n", countPoints, batchSize, got)
			}
			pkg.Tracer.Done()
		}
	}()
	i.Run(s)
}
Exemplo n.º 9
0
func testSetRunUtl(t *testing.T, property string, value string) {
	i := newTestSet(property, value)
	s, _, directiveCh := ponyExpress.NewTestStoreFront()
	// Listen to the other side of the directiveCh
	go func() {
		for d := range directiveCh {
			if i.Var != d.Property {
				t.Errorf("wrong property sent to ponyExpress\n  expected: %v\n got: %v\n", i.Var, d.Property)
			}
			if i.Value != d.Value {
				t.Errorf("wrong value sent to ponyExpress\n  expected: %v\n  got: %v\n", i.Value, d.Value)
			}
			d.Tracer.Done()
		}
	}()
	// Run the statement
	i.Run(s)
	// Check the result
	switch i.Var {
	case "precision":
		if i.Value != s.Precision {
			t.Errorf("Failed to set %v\n", i.Var)
		}
	case "startdate":
		if i.Value != s.StartDate {
			t.Errorf("Failed to set %v\n", i.Var)
		}
	case "batchsize":
		if parseInt(i.Value) != s.BatchSize {
			t.Errorf("Failed to set %v\n", i.Var)
		}
	// TODO: Actually test this
	case "resultsaddress":
	case "testname":
		if i.Value != s.TestName {
			t.Errorf("Failed to set %v\n", i.Var)
		}
	default:
	}
}