示例#1
0
文件: data_test.go 项目: eswdd/bosun
// Ensure a continuous query can be removed.
func TestData_DropContinuousQuery(t *testing.T) {
	var data meta.Data
	if err := data.CreateDatabase("db0"); err != nil {
		t.Fatal(err)
	} else if err := data.CreateContinuousQuery("db0", "cq0", "SELECT count() FROM foo"); err != nil {
		t.Fatal(err)
	} else if err = data.CreateContinuousQuery("db0", "cq1", "SELECT count() FROM bar"); err != nil {
		t.Fatal(err)
	}

	if err := data.DropContinuousQuery("db0", "cq0"); err != nil {
		t.Fatal(err)
	} else if !reflect.DeepEqual(data.Databases[0].ContinuousQueries, []meta.ContinuousQueryInfo{
		{Name: "cq1", Query: "SELECT count() FROM bar"},
	}) {
		t.Fatalf("unexpected queries: %#v", data.Databases[0].ContinuousQueries)
	}
}