Skip to content

Commit

Permalink
fix test error message
Browse files Browse the repository at this point in the history
  • Loading branch information
ifireice committed Mar 6, 2019
1 parent d0415e4 commit 58a4b2a
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions api/dto/triggers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"net/http"
"testing"
"fmt"

"github.com/moira-alert/moira/api/middleware"
"github.com/moira-alert/moira/metric_source"
Expand Down Expand Up @@ -65,7 +66,7 @@ func TestExpressionModeMultipleTargetsWarnValue (t *testing.T) {
tr := Trigger{trigger, throttling}
err := tr.Bind(request)
So(err, ShouldNotBeNil)
So(err.Error(), ShouldContainSubstring, "can't use 'expression' to trigger_type: 'falling'")
So(err, ShouldResemble, fmt.Errorf("can't use 'expression' to trigger_type: 'falling'"))
})

Convey("and warn_value and error_value", func() {
Expand All @@ -89,7 +90,7 @@ func TestExpressionModeMultipleTargetsWarnValue (t *testing.T) {
tr := Trigger{trigger, throttling}
err := tr.Bind(request)
So(err, ShouldNotBeNil)
So(err.Error(), ShouldContainSubstring, "can't use trigger_type not 'falling' for with multiple targets")
So(err, ShouldResemble, fmt.Errorf("can't use trigger_type not 'falling' for with multiple targets"))
})

})
Expand All @@ -105,7 +106,7 @@ func TestExpressionModeMultipleTargetsWarnValue (t *testing.T) {
tr := Trigger{trigger, throttling}
err := tr.Bind(request)
So(err, ShouldNotBeNil)
So(err.Error(), ShouldContainSubstring, "can't use 'expression' to trigger_type: 'rising'")
So(err, ShouldResemble, fmt.Errorf("can't use 'expression' to trigger_type: 'rising'"))
})

Convey("and warn_value and error_value", func() {
Expand All @@ -129,7 +130,7 @@ func TestExpressionModeMultipleTargetsWarnValue (t *testing.T) {
tr := Trigger{trigger, throttling}
err := tr.Bind(request)
So(err, ShouldNotBeNil)
So(err.Error(), ShouldContainSubstring, "can't use trigger_type not 'rising' for with multiple targets")
So(err, ShouldResemble, fmt.Errorf("can't use trigger_type not 'rising' for with multiple targets"))
})

})
Expand All @@ -147,22 +148,20 @@ func TestExpressionModeMultipleTargetsWarnValue (t *testing.T) {
tr := Trigger{trigger, throttling}
err := tr.Bind(request)
So(err, ShouldNotBeNil)
So(err.Error(), ShouldContainSubstring, "can't use 'warn_value' on trigger_type: 'expression'")
So(err, ShouldResemble, fmt.Errorf("can't use 'warn_value' on trigger_type: 'expression'"))
})

Convey("and error_value", func() {
trigger.ErrorValue = &errorValue
tr := Trigger{trigger, throttling}
err := tr.Bind(request)
So(err, ShouldNotBeNil)
So(err.Error(), ShouldContainSubstring, "can't use 'error_value' on trigger_type: 'expression'")

So(err, ShouldResemble, fmt.Errorf("can't use 'error_value' on trigger_type: 'expression'"))
})
Convey("and expression", func() {
tr := Trigger{trigger, throttling}
err := tr.Bind(request)
So(err, ShouldBeNil)

})
})
})
Expand Down

0 comments on commit 58a4b2a

Please sign in to comment.