mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Remove context.TODO() from services (#42555)
* Remove context.TODO() from services * Fix live test
This commit is contained in:
@@ -25,7 +25,7 @@ func TestAlertingEvaluationHandler(t *testing.T) {
|
||||
handler := NewEvalHandler(nil)
|
||||
|
||||
t.Run("Show return triggered with single passing condition", func(t *testing.T) {
|
||||
context := NewEvalContext(context.TODO(), &Rule{
|
||||
context := NewEvalContext(context.Background(), &Rule{
|
||||
Conditions: []Condition{&conditionStub{
|
||||
firing: true,
|
||||
}},
|
||||
@@ -37,7 +37,7 @@ func TestAlertingEvaluationHandler(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Show return triggered with single passing condition2", func(t *testing.T) {
|
||||
context := NewEvalContext(context.TODO(), &Rule{
|
||||
context := NewEvalContext(context.Background(), &Rule{
|
||||
Conditions: []Condition{&conditionStub{firing: true, operator: "and"}},
|
||||
}, &validations.OSSPluginRequestValidator{})
|
||||
|
||||
@@ -47,7 +47,7 @@ func TestAlertingEvaluationHandler(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Show return false with not passing asdf", func(t *testing.T) {
|
||||
context := NewEvalContext(context.TODO(), &Rule{
|
||||
context := NewEvalContext(context.Background(), &Rule{
|
||||
Conditions: []Condition{
|
||||
&conditionStub{firing: true, operator: "and", matches: []*EvalMatch{{}, {}}},
|
||||
&conditionStub{firing: false, operator: "and"},
|
||||
@@ -60,7 +60,7 @@ func TestAlertingEvaluationHandler(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Show return true if any of the condition is passing with OR operator", func(t *testing.T) {
|
||||
context := NewEvalContext(context.TODO(), &Rule{
|
||||
context := NewEvalContext(context.Background(), &Rule{
|
||||
Conditions: []Condition{
|
||||
&conditionStub{firing: true, operator: "and"},
|
||||
&conditionStub{firing: false, operator: "or"},
|
||||
@@ -73,7 +73,7 @@ func TestAlertingEvaluationHandler(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Show return false if any of the condition is failing with AND operator", func(t *testing.T) {
|
||||
context := NewEvalContext(context.TODO(), &Rule{
|
||||
context := NewEvalContext(context.Background(), &Rule{
|
||||
Conditions: []Condition{
|
||||
&conditionStub{firing: true, operator: "and"},
|
||||
&conditionStub{firing: false, operator: "and"},
|
||||
@@ -86,7 +86,7 @@ func TestAlertingEvaluationHandler(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Show return true if one condition is failing with nested OR operator", func(t *testing.T) {
|
||||
context := NewEvalContext(context.TODO(), &Rule{
|
||||
context := NewEvalContext(context.Background(), &Rule{
|
||||
Conditions: []Condition{
|
||||
&conditionStub{firing: true, operator: "and"},
|
||||
&conditionStub{firing: true, operator: "and"},
|
||||
@@ -100,7 +100,7 @@ func TestAlertingEvaluationHandler(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Show return false if one condition is passing with nested OR operator", func(t *testing.T) {
|
||||
context := NewEvalContext(context.TODO(), &Rule{
|
||||
context := NewEvalContext(context.Background(), &Rule{
|
||||
Conditions: []Condition{
|
||||
&conditionStub{firing: true, operator: "and"},
|
||||
&conditionStub{firing: false, operator: "and"},
|
||||
@@ -114,7 +114,7 @@ func TestAlertingEvaluationHandler(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Show return false if a condition is failing with nested AND operator", func(t *testing.T) {
|
||||
context := NewEvalContext(context.TODO(), &Rule{
|
||||
context := NewEvalContext(context.Background(), &Rule{
|
||||
Conditions: []Condition{
|
||||
&conditionStub{firing: true, operator: "and"},
|
||||
&conditionStub{firing: false, operator: "and"},
|
||||
@@ -128,7 +128,7 @@ func TestAlertingEvaluationHandler(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Show return true if a condition is passing with nested OR operator", func(t *testing.T) {
|
||||
context := NewEvalContext(context.TODO(), &Rule{
|
||||
context := NewEvalContext(context.Background(), &Rule{
|
||||
Conditions: []Condition{
|
||||
&conditionStub{firing: true, operator: "and"},
|
||||
&conditionStub{firing: false, operator: "or"},
|
||||
@@ -142,7 +142,7 @@ func TestAlertingEvaluationHandler(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Should return false if no condition is firing using OR operator", func(t *testing.T) {
|
||||
context := NewEvalContext(context.TODO(), &Rule{
|
||||
context := NewEvalContext(context.Background(), &Rule{
|
||||
Conditions: []Condition{
|
||||
&conditionStub{firing: false, operator: "or"},
|
||||
&conditionStub{firing: false, operator: "or"},
|
||||
@@ -157,7 +157,7 @@ func TestAlertingEvaluationHandler(t *testing.T) {
|
||||
|
||||
// FIXME: What should the actual test case name be here?
|
||||
t.Run("Should not return NoDataFound if all conditions have data and using OR", func(t *testing.T) {
|
||||
context := NewEvalContext(context.TODO(), &Rule{
|
||||
context := NewEvalContext(context.Background(), &Rule{
|
||||
Conditions: []Condition{
|
||||
&conditionStub{operator: "or", noData: false},
|
||||
&conditionStub{operator: "or", noData: false},
|
||||
@@ -170,7 +170,7 @@ func TestAlertingEvaluationHandler(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Should return NoDataFound if one condition has no data", func(t *testing.T) {
|
||||
context := NewEvalContext(context.TODO(), &Rule{
|
||||
context := NewEvalContext(context.Background(), &Rule{
|
||||
Conditions: []Condition{
|
||||
&conditionStub{operator: "and", noData: true},
|
||||
},
|
||||
@@ -182,7 +182,7 @@ func TestAlertingEvaluationHandler(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Should return no data if at least one condition has no data and using AND", func(t *testing.T) {
|
||||
context := NewEvalContext(context.TODO(), &Rule{
|
||||
context := NewEvalContext(context.Background(), &Rule{
|
||||
Conditions: []Condition{
|
||||
&conditionStub{operator: "and", noData: true},
|
||||
&conditionStub{operator: "and", noData: false},
|
||||
@@ -194,7 +194,7 @@ func TestAlertingEvaluationHandler(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("Should return no data if at least one condition has no data and using OR", func(t *testing.T) {
|
||||
context := NewEvalContext(context.TODO(), &Rule{
|
||||
context := NewEvalContext(context.Background(), &Rule{
|
||||
Conditions: []Condition{
|
||||
&conditionStub{operator: "or", noData: true},
|
||||
&conditionStub{operator: "or", noData: false},
|
||||
|
||||
Reference in New Issue
Block a user