Skip to content

Commit

Permalink
tests: pass test to test expression
Browse files Browse the repository at this point in the history
so in cases of a panicing expression test, the test can be identified
  • Loading branch information
kylebrandt committed Sep 25, 2018
1 parent 1651b33 commit 70d82b9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
12 changes: 6 additions & 6 deletions cmd/bosun/expr/expr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func TestQueryExpr(t *testing.T) {
tests := map[string]map[string]Value{
`window("avg:m{a=*}", "5m", "1h", 2, "max")`: {
"a=b": Series{
d: 2,
d: 2,
d.Add(time.Second * 2): 6,
},
"a=c": Series{
Expand All @@ -176,7 +176,7 @@ func TestQueryExpr(t *testing.T) {
},
`window("avg:m{a=*}", "5m", "1h", 2, "avg")`: {
"a=b": Series{
d: 1.5,
d: 1.5,
d.Add(time.Second * 2): 5,
},
"a=c": Series{
Expand All @@ -188,7 +188,7 @@ func TestQueryExpr(t *testing.T) {
},
`over("avg:m{a=*}", "5m", "1h", 3)`: {
"a=b,shift=0s": Series{
d: 0,
d: 0,
d.Add(time.Second * 1): 3,
},
"a=b,shift=1h0m0s": Series{
Expand All @@ -214,7 +214,7 @@ func TestQueryExpr(t *testing.T) {
},
`band("avg:m{a=*}", "5m", "1h", 2)`: {
"a=b": Series{
d: 1,
d: 1,
d.Add(time.Second * 1): 2,
d.Add(time.Second * 2): 6,
d.Add(time.Second * 3): 4,
Expand Down Expand Up @@ -397,7 +397,7 @@ func TestSetVariant(t *testing.T) {
},
}
for _, test := range tests {
err := testExpression(test)
err := testExpression(test, t)
if err != nil {
t.Error(err)
}
Expand Down Expand Up @@ -458,7 +458,7 @@ func TestSeriesOperations(t *testing.T) {
},
}
for _, test := range tests {
err := testExpression(test)
err := testExpression(test, t)
if err != nil {
t.Error(err)
}
Expand Down
18 changes: 9 additions & 9 deletions cmd/bosun/expr/funcs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type exprInOut struct {
shouldParseErr bool
}

func testExpression(eio exprInOut) error {
func testExpression(eio exprInOut, t *testing.T) error {
e, err := New(eio.expr, builtins)
if eio.shouldParseErr {
if err == nil {
Expand Down Expand Up @@ -54,7 +54,7 @@ func TestDuration(t *testing.T) {
},
false,
}
err := testExpression(d)
err := testExpression(d, t)
if err != nil {
t.Error(err)
}
Expand Down Expand Up @@ -92,7 +92,7 @@ func TestToDuration(t *testing.T) {
},
false,
}
err := testExpression(d)
err := testExpression(d, t)
if err != nil {
t.Error(err)
}
Expand All @@ -114,7 +114,7 @@ func TestUngroup(t *testing.T) {
},
},
false,
})
}, t)

if err != nil {
t.Error(err)
Expand Down Expand Up @@ -143,7 +143,7 @@ func TestMerge(t *testing.T) {
},
},
false,
})
}, t)
if err != nil {
t.Error(err)
}
Expand All @@ -168,7 +168,7 @@ func TestMerge(t *testing.T) {
},
},
false,
})
}, t)
if err == nil {
t.Errorf("error expected due to identical groups in merge but did not get one")
}
Expand Down Expand Up @@ -205,7 +205,7 @@ func TestTimedelta(t *testing.T) {
},
},
false,
})
}, t)

if err != nil {
t.Error(err)
Expand Down Expand Up @@ -251,7 +251,7 @@ func TestTail(t *testing.T) {
},
},
false,
})
}, t)

if err != nil {
t.Error(err)
Expand Down Expand Up @@ -491,7 +491,7 @@ func TestAggr(t *testing.T) {
expr: tc.expr,
out: tc.want,
shouldParseErr: false,
})
}, t)
if !tc.shouldErr && err != nil {
t.Errorf("Case %q: Got error: %v", tc.name, err)
} else if tc.shouldErr && err == nil {
Expand Down
18 changes: 9 additions & 9 deletions cmd/bosun/expr/map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestMap(t *testing.T) {
},
},
false,
})
}, t)
if err != nil {
t.Error(err)
}
Expand All @@ -38,7 +38,7 @@ func TestMap(t *testing.T) {
},
},
false,
})
}, t)
if err != nil {
t.Error(err)
}
Expand All @@ -54,7 +54,7 @@ func TestMap(t *testing.T) {
},
},
false,
})
}, t)
if err != nil {
t.Error(err)
}
Expand All @@ -70,7 +70,7 @@ func TestMap(t *testing.T) {
},
},
false,
})
}, t)
if err != nil {
t.Error(err)
}
Expand All @@ -89,7 +89,7 @@ func TestMap(t *testing.T) {
},
},
false,
})
}, t)
if err != nil {
t.Error(err)
}
Expand All @@ -108,7 +108,7 @@ func TestMap(t *testing.T) {
},
},
false,
})
}, t)
if err != nil {
t.Error(err)
}
Expand All @@ -124,7 +124,7 @@ func TestMap(t *testing.T) {
},
},
true, // expect parse error here, series result not valid as TypeNumberExpr
})
}, t)
if err != nil {
t.Error(err)
}
Expand All @@ -140,7 +140,7 @@ func TestMap(t *testing.T) {
},
},
true, // v() is not valid outside a map expression
})
}, t)
if err != nil {
t.Error(err)
}
Expand All @@ -159,7 +159,7 @@ func TestMap(t *testing.T) {
},
},
false,
})
}, t)
if err != nil {
t.Error(err)
}
Expand Down

0 comments on commit 70d82b9

Please sign in to comment.