mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Fix various spelling errors in back-end code (#25241)
* Chore: Fix various spelling errors in back-end code Co-authored-by: Sofia Papagiannaki <papagian@users.noreply.github.com> Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>>
This commit is contained in:
@@ -77,7 +77,7 @@ func TestParsingAlertRuleSettings(t *testing.T) {
|
||||
shouldErr require.ErrorAssertionFunc
|
||||
}{
|
||||
{
|
||||
name: "can parse singel condition",
|
||||
name: "can parse single condition",
|
||||
file: "testdata/settings/one_condition.json",
|
||||
expected: []int64{3},
|
||||
shouldErr: require.NoError,
|
||||
|
||||
@@ -14,8 +14,8 @@ var (
|
||||
rangedTypes = []string{"within_range", "outside_range"}
|
||||
)
|
||||
|
||||
// AlertEvaluator evaluates the reduced value of a timeserie.
|
||||
// Returning true if a timeserie is violating the condition
|
||||
// AlertEvaluator evaluates the reduced value of a timeseries.
|
||||
// Returning true if a timeseries is violating the condition
|
||||
// ex: ThresholdEvaluator, NoValueEvaluator, RangeEvaluator
|
||||
type AlertEvaluator interface {
|
||||
Eval(reducedValue null.Float) bool
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/components/simplejson"
|
||||
)
|
||||
|
||||
func evalutorScenario(json string, reducedValue float64, datapoints ...float64) bool {
|
||||
func evaluatorScenario(json string, reducedValue float64, datapoints ...float64) bool {
|
||||
jsonModel, err := simplejson.NewJson([]byte(json))
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
@@ -19,37 +19,37 @@ func evalutorScenario(json string, reducedValue float64, datapoints ...float64)
|
||||
return evaluator.Eval(null.FloatFrom(reducedValue))
|
||||
}
|
||||
|
||||
func TestEvalutors(t *testing.T) {
|
||||
func TestEvaluators(t *testing.T) {
|
||||
Convey("greater then", t, func() {
|
||||
So(evalutorScenario(`{"type": "gt", "params": [1] }`, 3), ShouldBeTrue)
|
||||
So(evalutorScenario(`{"type": "gt", "params": [3] }`, 1), ShouldBeFalse)
|
||||
So(evaluatorScenario(`{"type": "gt", "params": [1] }`, 3), ShouldBeTrue)
|
||||
So(evaluatorScenario(`{"type": "gt", "params": [3] }`, 1), ShouldBeFalse)
|
||||
})
|
||||
|
||||
Convey("less then", t, func() {
|
||||
So(evalutorScenario(`{"type": "lt", "params": [1] }`, 3), ShouldBeFalse)
|
||||
So(evalutorScenario(`{"type": "lt", "params": [3] }`, 1), ShouldBeTrue)
|
||||
So(evaluatorScenario(`{"type": "lt", "params": [1] }`, 3), ShouldBeFalse)
|
||||
So(evaluatorScenario(`{"type": "lt", "params": [3] }`, 1), ShouldBeTrue)
|
||||
})
|
||||
|
||||
Convey("within_range", t, func() {
|
||||
So(evalutorScenario(`{"type": "within_range", "params": [1, 100] }`, 3), ShouldBeTrue)
|
||||
So(evalutorScenario(`{"type": "within_range", "params": [1, 100] }`, 300), ShouldBeFalse)
|
||||
So(evalutorScenario(`{"type": "within_range", "params": [100, 1] }`, 3), ShouldBeTrue)
|
||||
So(evalutorScenario(`{"type": "within_range", "params": [100, 1] }`, 300), ShouldBeFalse)
|
||||
So(evaluatorScenario(`{"type": "within_range", "params": [1, 100] }`, 3), ShouldBeTrue)
|
||||
So(evaluatorScenario(`{"type": "within_range", "params": [1, 100] }`, 300), ShouldBeFalse)
|
||||
So(evaluatorScenario(`{"type": "within_range", "params": [100, 1] }`, 3), ShouldBeTrue)
|
||||
So(evaluatorScenario(`{"type": "within_range", "params": [100, 1] }`, 300), ShouldBeFalse)
|
||||
})
|
||||
|
||||
Convey("outside_range", t, func() {
|
||||
So(evalutorScenario(`{"type": "outside_range", "params": [1, 100] }`, 1000), ShouldBeTrue)
|
||||
So(evalutorScenario(`{"type": "outside_range", "params": [1, 100] }`, 50), ShouldBeFalse)
|
||||
So(evalutorScenario(`{"type": "outside_range", "params": [100, 1] }`, 1000), ShouldBeTrue)
|
||||
So(evalutorScenario(`{"type": "outside_range", "params": [100, 1] }`, 50), ShouldBeFalse)
|
||||
So(evaluatorScenario(`{"type": "outside_range", "params": [1, 100] }`, 1000), ShouldBeTrue)
|
||||
So(evaluatorScenario(`{"type": "outside_range", "params": [1, 100] }`, 50), ShouldBeFalse)
|
||||
So(evaluatorScenario(`{"type": "outside_range", "params": [100, 1] }`, 1000), ShouldBeTrue)
|
||||
So(evaluatorScenario(`{"type": "outside_range", "params": [100, 1] }`, 50), ShouldBeFalse)
|
||||
})
|
||||
|
||||
Convey("no_value", t, func() {
|
||||
Convey("should be false if serie have values", func() {
|
||||
So(evalutorScenario(`{"type": "no_value", "params": [] }`, 50), ShouldBeFalse)
|
||||
Convey("should be false if series have values", func() {
|
||||
So(evaluatorScenario(`{"type": "no_value", "params": [] }`, 50), ShouldBeFalse)
|
||||
})
|
||||
|
||||
Convey("should be true when the serie have no value", func() {
|
||||
Convey("should be true when the series have no value", func() {
|
||||
jsonModel, err := simplejson.NewJson([]byte(`{"type": "no_value", "params": [] }`))
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ func TestQueryCondition(t *testing.T) {
|
||||
So(cr.Firing, ShouldBeFalse)
|
||||
})
|
||||
|
||||
Convey("Should fire if only first serie matches", func() {
|
||||
Convey("Should fire if only first series matches", func() {
|
||||
ctx.series = tsdb.TimeSeriesSlice{
|
||||
tsdb.NewTimeSeries("test1", tsdb.NewTimeSeriesPointsFromArgs(120, 0)),
|
||||
tsdb.NewTimeSeries("test2", tsdb.NewTimeSeriesPointsFromArgs(0, 0)),
|
||||
@@ -149,7 +149,7 @@ func TestQueryCondition(t *testing.T) {
|
||||
So(cr.NoDataFound, ShouldBeTrue)
|
||||
})
|
||||
|
||||
Convey("Should not set NoDataFound if one serie is empty", func() {
|
||||
Convey("Should not set NoDataFound if one series is empty", func() {
|
||||
ctx.series = tsdb.TimeSeriesSlice{
|
||||
tsdb.NewTimeSeries("test1", tsdb.NewTimeSeriesPointsFromArgs()),
|
||||
tsdb.NewTimeSeries("test2", tsdb.NewTimeSeriesPointsFromArgs(120, 0)),
|
||||
|
||||
@@ -9,10 +9,10 @@ import (
|
||||
"github.com/grafana/grafana/pkg/tsdb"
|
||||
)
|
||||
|
||||
// queryReducer reduces an timeserie to a nullable float
|
||||
// queryReducer reduces a timeseries to a nullable float
|
||||
type queryReducer struct {
|
||||
|
||||
// Type is how the timeserie should be reduced.
|
||||
// Type is how the timeseries should be reduced.
|
||||
// Ex avg, sum, max, min, count
|
||||
Type string
|
||||
}
|
||||
|
||||
@@ -153,7 +153,8 @@ func TestAlertingEvaluationHandler(t *testing.T) {
|
||||
So(context.ConditionEvals, ShouldEqual, "[[false OR false] OR false] = false")
|
||||
})
|
||||
|
||||
Convey("Should retuasdfrn no data if one condition has nodata", func() {
|
||||
// FIXME: What should the actual test case name be here?
|
||||
Convey("Should not return NoDataFound if all conditions have data and using OR", func() {
|
||||
context := NewEvalContext(context.TODO(), &Rule{
|
||||
Conditions: []Condition{
|
||||
&conditionStub{operator: "or", noData: false},
|
||||
@@ -166,7 +167,7 @@ func TestAlertingEvaluationHandler(t *testing.T) {
|
||||
So(context.NoDataFound, ShouldBeFalse)
|
||||
})
|
||||
|
||||
Convey("Should return no data if one condition has nodata", func() {
|
||||
Convey("Should return NoDataFound if one condition has no data", func() {
|
||||
context := NewEvalContext(context.TODO(), &Rule{
|
||||
Conditions: []Condition{
|
||||
&conditionStub{operator: "and", noData: true},
|
||||
@@ -178,7 +179,7 @@ func TestAlertingEvaluationHandler(t *testing.T) {
|
||||
So(context.NoDataFound, ShouldBeTrue)
|
||||
})
|
||||
|
||||
Convey("Should return no data if both conditions have no data and using AND", func() {
|
||||
Convey("Should not return no data if at least one condition has no data and using AND", func() {
|
||||
context := NewEvalContext(context.TODO(), &Rule{
|
||||
Conditions: []Condition{
|
||||
&conditionStub{operator: "and", noData: true},
|
||||
@@ -190,7 +191,7 @@ func TestAlertingEvaluationHandler(t *testing.T) {
|
||||
So(context.NoDataFound, ShouldBeFalse)
|
||||
})
|
||||
|
||||
Convey("Should not return no data if both conditions have no data and using OR", func() {
|
||||
Convey("Should return no data if at least one condition has no data and using OR", func() {
|
||||
context := NewEvalContext(context.TODO(), &Rule{
|
||||
Conditions: []Condition{
|
||||
&conditionStub{operator: "or", noData: true},
|
||||
|
||||
@@ -36,7 +36,7 @@ type ResultLogEntry struct {
|
||||
Data interface{}
|
||||
}
|
||||
|
||||
// EvalMatch represents the serie violating the threshold.
|
||||
// EvalMatch represents the series violating the threshold.
|
||||
type EvalMatch struct {
|
||||
Value null.Float `json:"value"`
|
||||
Metric string `json:"metric"`
|
||||
|
||||
@@ -234,7 +234,7 @@ type testNotifier struct {
|
||||
Name string
|
||||
Type string
|
||||
UID string
|
||||
IsDeault bool
|
||||
IsDefault bool
|
||||
UploadImage bool
|
||||
SendReminder bool
|
||||
DisableResolveMessage bool
|
||||
@@ -251,7 +251,7 @@ func newTestNotifier(model *models.AlertNotification) (Notifier, error) {
|
||||
return &testNotifier{
|
||||
UID: model.Uid,
|
||||
Name: model.Name,
|
||||
IsDeault: model.IsDefault,
|
||||
IsDefault: model.IsDefault,
|
||||
Type: model.Type,
|
||||
UploadImage: uploadImage,
|
||||
SendReminder: model.SendReminder,
|
||||
@@ -267,7 +267,7 @@ func (n *testNotifier) Notify(evalCtx *EvalContext) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (n *testNotifier) ShouldNotify(ctx context.Context, evalCtx *EvalContext, notiferState *models.AlertNotificationState) bool {
|
||||
func (n *testNotifier) ShouldNotify(ctx context.Context, evalCtx *EvalContext, notifierState *models.AlertNotificationState) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ func (n *testNotifier) GetNotifierUID() string {
|
||||
}
|
||||
|
||||
func (n *testNotifier) GetIsDefault() bool {
|
||||
return n.IsDeault
|
||||
return n.IsDefault
|
||||
}
|
||||
|
||||
func (n *testNotifier) GetSendReminder() bool {
|
||||
|
||||
@@ -49,7 +49,7 @@ func NewNotifierBase(model *models.AlertNotification) NotifierBase {
|
||||
}
|
||||
|
||||
// ShouldNotify checks this evaluation should send an alert notification
|
||||
func (n *NotifierBase) ShouldNotify(ctx context.Context, context *alerting.EvalContext, notiferState *models.AlertNotificationState) bool {
|
||||
func (n *NotifierBase) ShouldNotify(ctx context.Context, context *alerting.EvalContext, notifierState *models.AlertNotificationState) bool {
|
||||
prevState := context.PrevAlertState
|
||||
newState := context.Rule.State
|
||||
|
||||
@@ -60,8 +60,8 @@ func (n *NotifierBase) ShouldNotify(ctx context.Context, context *alerting.EvalC
|
||||
|
||||
if prevState == newState && n.SendReminder {
|
||||
// Do not notify if interval has not elapsed
|
||||
lastNotify := time.Unix(notiferState.UpdatedAt, 0)
|
||||
if notiferState.UpdatedAt != 0 && lastNotify.Add(n.Frequency).After(time.Now()) {
|
||||
lastNotify := time.Unix(notifierState.UpdatedAt, 0)
|
||||
if notifierState.UpdatedAt != 0 && lastNotify.Add(n.Frequency).After(time.Now()) {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -94,8 +94,8 @@ func (n *NotifierBase) ShouldNotify(ctx context.Context, context *alerting.EvalC
|
||||
}
|
||||
|
||||
// Do not notify if state pending and it have been updated last minute
|
||||
if notiferState.State == models.AlertNotificationStatePending {
|
||||
lastUpdated := time.Unix(notiferState.UpdatedAt, 0)
|
||||
if notifierState.State == models.AlertNotificationStatePending {
|
||||
lastUpdated := time.Unix(notifierState.UpdatedAt, 0)
|
||||
if lastUpdated.Add(1 * time.Minute).After(time.Now()) {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ func TestShouldSendAlertNotification(t *testing.T) {
|
||||
expect: false,
|
||||
},
|
||||
{
|
||||
name: "alerting -> alerting with reminder and last notifciation sent 11 minutes ago should trigger",
|
||||
name: "alerting -> alerting with reminder and last notification sent 11 minutes ago should trigger",
|
||||
newState: models.AlertStateAlerting,
|
||||
prevState: models.AlertStateAlerting,
|
||||
frequency: time.Minute * 10,
|
||||
@@ -114,7 +114,7 @@ func TestShouldSendAlertNotification(t *testing.T) {
|
||||
expect: true,
|
||||
},
|
||||
{
|
||||
name: "OK -> alerting with notifciation state pending and updated 30 seconds ago should not trigger",
|
||||
name: "OK -> alerting with notification state pending and updated 30 seconds ago should not trigger",
|
||||
newState: models.AlertStateAlerting,
|
||||
prevState: models.AlertStateOK,
|
||||
state: &models.AlertNotificationState{State: models.AlertNotificationStatePending, UpdatedAt: tnow.Add(-30 * time.Second).Unix()},
|
||||
@@ -122,7 +122,7 @@ func TestShouldSendAlertNotification(t *testing.T) {
|
||||
expect: false,
|
||||
},
|
||||
{
|
||||
name: "OK -> alerting with notifciation state pending and updated 2 minutes ago should trigger",
|
||||
name: "OK -> alerting with notification state pending and updated 2 minutes ago should trigger",
|
||||
newState: models.AlertStateAlerting,
|
||||
prevState: models.AlertStateOK,
|
||||
state: &models.AlertNotificationState{State: models.AlertNotificationStatePending, UpdatedAt: tnow.Add(-2 * time.Minute).Unix()},
|
||||
|
||||
@@ -103,10 +103,10 @@ func (en *EmailNotifier) Notify(evalContext *alerting.EvalContext) error {
|
||||
"AlertPageUrl": setting.AppUrl + "alerting",
|
||||
"EvalMatches": evalContext.EvalMatches,
|
||||
},
|
||||
To: en.Addresses,
|
||||
SingleEmail: en.SingleEmail,
|
||||
Template: "alert_notification.html",
|
||||
EmbededFiles: []string{},
|
||||
To: en.Addresses,
|
||||
SingleEmail: en.SingleEmail,
|
||||
Template: "alert_notification.html",
|
||||
EmbeddedFiles: []string{},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ func (en *EmailNotifier) Notify(evalContext *alerting.EvalContext) error {
|
||||
} else {
|
||||
file, err := os.Stat(evalContext.ImageOnDiskPath)
|
||||
if err == nil {
|
||||
cmd.EmbededFiles = []string{evalContext.ImageOnDiskPath}
|
||||
cmd.EmbeddedFiles = []string{evalContext.ImageOnDiskPath}
|
||||
cmd.Data["EmbeddedImage"] = file.Name()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ func getTimeDurationStringToSeconds(str string) (int64, error) {
|
||||
return int64(value * multiplier), nil
|
||||
}
|
||||
|
||||
// NewRuleFromDBAlert mappes an db version of
|
||||
// NewRuleFromDBAlert maps a db version of
|
||||
// alert to an in-memory version.
|
||||
func NewRuleFromDBAlert(ruleDef *models.Alert) (*Rule, error) {
|
||||
model := &Rule{}
|
||||
@@ -130,7 +130,7 @@ func NewRuleFromDBAlert(ruleDef *models.Alert) (*Rule, error) {
|
||||
|
||||
model.Frequency = ruleDef.Frequency
|
||||
// frequency cannot be zero since that would not execute the alert rule.
|
||||
// so we fallback to 60 seconds if `Freqency` is missing
|
||||
// so we fallback to 60 seconds if `Frequency` is missing
|
||||
if model.Frequency == 0 {
|
||||
model.Frequency = 60
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ func TestGuardianAdmin(t *testing.T) {
|
||||
sc.parentFolderPermissionScenario(EDITOR, models.PERMISSION_EDIT, FULL_ACCESS)
|
||||
sc.parentFolderPermissionScenario(EDITOR, models.PERMISSION_VIEW, FULL_ACCESS)
|
||||
|
||||
// parent folder has viweer role with permission
|
||||
// parent folder has viewer role with permission
|
||||
sc.parentFolderPermissionScenario(VIEWER, models.PERMISSION_ADMIN, FULL_ACCESS)
|
||||
sc.parentFolderPermissionScenario(VIEWER, models.PERMISSION_EDIT, FULL_ACCESS)
|
||||
sc.parentFolderPermissionScenario(VIEWER, models.PERMISSION_VIEW, FULL_ACCESS)
|
||||
@@ -114,7 +114,7 @@ func TestGuardianEditor(t *testing.T) {
|
||||
sc.parentFolderPermissionScenario(EDITOR, models.PERMISSION_EDIT, EDITOR_ACCESS)
|
||||
sc.parentFolderPermissionScenario(EDITOR, models.PERMISSION_VIEW, VIEWER_ACCESS)
|
||||
|
||||
// parent folder has viweer role with permission
|
||||
// parent folder has viewer role with permission
|
||||
sc.parentFolderPermissionScenario(VIEWER, models.PERMISSION_ADMIN, NO_ACCESS)
|
||||
sc.parentFolderPermissionScenario(VIEWER, models.PERMISSION_EDIT, NO_ACCESS)
|
||||
sc.parentFolderPermissionScenario(VIEWER, models.PERMISSION_VIEW, NO_ACCESS)
|
||||
@@ -163,7 +163,7 @@ func TestGuardianViewer(t *testing.T) {
|
||||
sc.parentFolderPermissionScenario(EDITOR, models.PERMISSION_EDIT, NO_ACCESS)
|
||||
sc.parentFolderPermissionScenario(EDITOR, models.PERMISSION_VIEW, NO_ACCESS)
|
||||
|
||||
// parent folder has viweer role with permission
|
||||
// parent folder has viewer role with permission
|
||||
sc.parentFolderPermissionScenario(VIEWER, models.PERMISSION_ADMIN, FULL_ACCESS)
|
||||
sc.parentFolderPermissionScenario(VIEWER, models.PERMISSION_EDIT, EDITOR_ACCESS)
|
||||
sc.parentFolderPermissionScenario(VIEWER, models.PERMISSION_VIEW, VIEWER_ACCESS)
|
||||
@@ -549,7 +549,7 @@ func (sc *scenarioContext) verifyUpdateChildDashboardPermissionsShouldNotBeAllow
|
||||
newDefaultTeamPermission(childDashboardID, p),
|
||||
}
|
||||
|
||||
// perminssion to update is higher than parent folder permission
|
||||
// permission to update is higher than parent folder permission
|
||||
if p > parentFolderPermission {
|
||||
permissionList = append(permissionList, newEditorRolePermission(childDashboardID, p))
|
||||
}
|
||||
@@ -560,7 +560,7 @@ func (sc *scenarioContext) verifyUpdateChildDashboardPermissionsShouldNotBeAllow
|
||||
newDefaultTeamPermission(childDashboardID, p),
|
||||
}
|
||||
|
||||
// perminssion to update is higher than parent folder permission
|
||||
// permission to update is higher than parent folder permission
|
||||
if p > parentFolderPermission {
|
||||
permissionList = append(permissionList, newViewerRolePermission(childDashboardID, p))
|
||||
}
|
||||
@@ -586,7 +586,7 @@ func (sc *scenarioContext) verifyUpdateChildDashboardPermissionsWithOverrideShou
|
||||
}
|
||||
|
||||
for _, p := range []models.PermissionType{models.PERMISSION_ADMIN, models.PERMISSION_EDIT, models.PERMISSION_VIEW} {
|
||||
// perminssion to update is higher tban parent folder permission
|
||||
// permission to update is higher than parent folder permission
|
||||
if p > parentFolderPermission {
|
||||
continue
|
||||
}
|
||||
@@ -631,7 +631,7 @@ func (sc *scenarioContext) verifyUpdateChildDashboardPermissionsWithOverrideShou
|
||||
}
|
||||
|
||||
for _, p := range []models.PermissionType{models.PERMISSION_ADMIN, models.PERMISSION_EDIT, models.PERMISSION_VIEW} {
|
||||
// perminssion to update is lower than/equal parent folder permission
|
||||
// permission to update is lower than or equal to parent folder permission
|
||||
if p <= parentFolderPermission {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -453,7 +453,7 @@ func (server *Server) AdminBind() error {
|
||||
err := server.userBind(server.Config.BindDN, server.Config.BindPassword)
|
||||
if err != nil {
|
||||
server.log.Error(
|
||||
"Cannot authentificate admin user in LDAP",
|
||||
"Cannot authenticate admin user in LDAP",
|
||||
"error",
|
||||
err,
|
||||
)
|
||||
|
||||
@@ -121,7 +121,7 @@ func TestLDAPLogin(t *testing.T) {
|
||||
So(resp.Login, ShouldEqual, "markelog")
|
||||
})
|
||||
|
||||
Convey("Should perform unauthentificate bind without admin", func() {
|
||||
Convey("Should perform unauthenticated bind without admin", func() {
|
||||
connection := &MockConnection{}
|
||||
entry := ldap.Entry{
|
||||
DN: "test",
|
||||
@@ -147,7 +147,7 @@ func TestLDAPLogin(t *testing.T) {
|
||||
So(connection.UnauthenticatedBindCalled, ShouldBeTrue)
|
||||
})
|
||||
|
||||
Convey("Should perform authentificate binds", func() {
|
||||
Convey("Should perform authenticated binds", func() {
|
||||
connection := &MockConnection{}
|
||||
entry := ldap.Entry{
|
||||
DN: "test",
|
||||
|
||||
@@ -20,7 +20,7 @@ type Message struct {
|
||||
Body string
|
||||
Info string
|
||||
ReplyTo []string
|
||||
EmbededFiles []string
|
||||
EmbeddedFiles []string
|
||||
AttachedFiles []*AttachedFile
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ func (ns *NotificationService) setFiles(
|
||||
m *gomail.Message,
|
||||
msg *Message,
|
||||
) {
|
||||
for _, file := range msg.EmbededFiles {
|
||||
for _, file := range msg.EmbeddedFiles {
|
||||
m.Embed(file)
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ func (ns *NotificationService) buildEmailMessage(cmd *models.SendEmailCommand) (
|
||||
From: fmt.Sprintf("%s <%s>", ns.Cfg.Smtp.FromName, ns.Cfg.Smtp.FromAddress),
|
||||
Subject: subject,
|
||||
Body: buffer.String(),
|
||||
EmbededFiles: cmd.EmbededFiles,
|
||||
EmbeddedFiles: cmd.EmbeddedFiles,
|
||||
AttachedFiles: buildAttachedFiles(cmd.AttachedFiles),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -119,13 +119,13 @@ func subjectTemplateFunc(obj map[string]interface{}, value string) string {
|
||||
|
||||
func (ns *NotificationService) sendEmailCommandHandlerSync(ctx context.Context, cmd *models.SendEmailCommandSync) error {
|
||||
message, err := ns.buildEmailMessage(&models.SendEmailCommand{
|
||||
Data: cmd.Data,
|
||||
Info: cmd.Info,
|
||||
Template: cmd.Template,
|
||||
To: cmd.To,
|
||||
SingleEmail: cmd.SingleEmail,
|
||||
EmbededFiles: cmd.EmbededFiles,
|
||||
Subject: cmd.Subject,
|
||||
Data: cmd.Data,
|
||||
Info: cmd.Info,
|
||||
Template: cmd.Template,
|
||||
To: cmd.To,
|
||||
SingleEmail: cmd.SingleEmail,
|
||||
EmbeddedFiles: cmd.EmbeddedFiles,
|
||||
Subject: cmd.Subject,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
|
||||
@@ -30,9 +30,9 @@ func TestEmailIntegrationTest(t *testing.T) {
|
||||
cmd := &models.SendEmailCommand{
|
||||
|
||||
Data: map[string]interface{}{
|
||||
"Title": "[CRITICAL] Imaginary timeserie alert",
|
||||
"Title": "[CRITICAL] Imaginary timeseries alert",
|
||||
"State": "Firing",
|
||||
"Name": "Imaginary timeserie alert",
|
||||
"Name": "Imaginary timeseries alert",
|
||||
"Severity": "ok",
|
||||
"SeverityColor": "#D63232",
|
||||
"Message": "Alert message that will support markdown in some distant future.",
|
||||
|
||||
@@ -13,7 +13,7 @@ var (
|
||||
symlinkedFolder = "testdata/test-dashboards/symlink"
|
||||
)
|
||||
|
||||
func TestProvsionedSymlinkedFolder(t *testing.T) {
|
||||
func TestProvisionedSymlinkedFolder(t *testing.T) {
|
||||
cfg := &config{
|
||||
Name: "Default",
|
||||
Type: "file",
|
||||
|
||||
@@ -150,8 +150,8 @@ func TestDatasourceAsConfig(t *testing.T) {
|
||||
})
|
||||
|
||||
Convey("skip invalid directory", func() {
|
||||
cfgProvifer := &configReader{log: log.New("test logger")}
|
||||
cfg, err := cfgProvifer.readConfig("./invalid-directory")
|
||||
cfgProvider := &configReader{log: log.New("test logger")}
|
||||
cfg, err := cfgProvider.readConfig("./invalid-directory")
|
||||
if err != nil {
|
||||
t.Fatalf("readConfig return an error %v", err)
|
||||
}
|
||||
@@ -161,8 +161,8 @@ func TestDatasourceAsConfig(t *testing.T) {
|
||||
|
||||
Convey("can read all properties from version 1", func() {
|
||||
_ = os.Setenv("TEST_VAR", "name")
|
||||
cfgProvifer := &configReader{log: log.New("test logger")}
|
||||
cfg, err := cfgProvifer.readConfig(allProperties)
|
||||
cfgProvider := &configReader{log: log.New("test logger")}
|
||||
cfg, err := cfgProvider.readConfig(allProperties)
|
||||
_ = os.Unsetenv("TEST_VAR")
|
||||
if err != nil {
|
||||
t.Fatalf("readConfig return an error %v", err)
|
||||
@@ -190,8 +190,8 @@ func TestDatasourceAsConfig(t *testing.T) {
|
||||
})
|
||||
|
||||
Convey("can read all properties from version 0", func() {
|
||||
cfgProvifer := &configReader{log: log.New("test logger")}
|
||||
cfg, err := cfgProvifer.readConfig(versionZero)
|
||||
cfgProvider := &configReader{log: log.New("test logger")}
|
||||
cfg, err := cfgProvider.readConfig(versionZero)
|
||||
if err != nil {
|
||||
t.Fatalf("readConfig return an error %v", err)
|
||||
}
|
||||
|
||||
@@ -45,8 +45,8 @@ func TestNotificationAsConfig(t *testing.T) {
|
||||
|
||||
Convey("Can read correct properties", func() {
|
||||
_ = os.Setenv("TEST_VAR", "default")
|
||||
cfgProvifer := &configReader{log: log.New("test logger")}
|
||||
cfg, err := cfgProvifer.readConfig(correct_properties)
|
||||
cfgProvider := &configReader{log: log.New("test logger")}
|
||||
cfg, err := cfgProvider.readConfig(correct_properties)
|
||||
_ = os.Unsetenv("TEST_VAR")
|
||||
if err != nil {
|
||||
t.Fatalf("readConfig return an error %v", err)
|
||||
@@ -293,8 +293,8 @@ func TestNotificationAsConfig(t *testing.T) {
|
||||
})
|
||||
|
||||
Convey("Skip invalid directory", func() {
|
||||
cfgProvifer := &configReader{log: log.New("test logger")}
|
||||
cfg, err := cfgProvifer.readConfig(emptyFolder)
|
||||
cfgProvider := &configReader{log: log.New("test logger")}
|
||||
cfg, err := cfgProvider.readConfig(emptyFolder)
|
||||
if err != nil {
|
||||
t.Fatalf("readConfig return an error %v", err)
|
||||
}
|
||||
@@ -302,15 +302,15 @@ func TestNotificationAsConfig(t *testing.T) {
|
||||
})
|
||||
|
||||
Convey("Unknown notifier should return error", func() {
|
||||
cfgProvifer := &configReader{log: log.New("test logger")}
|
||||
_, err := cfgProvifer.readConfig(unknownNotifier)
|
||||
cfgProvider := &configReader{log: log.New("test logger")}
|
||||
_, err := cfgProvider.readConfig(unknownNotifier)
|
||||
So(err, ShouldNotBeNil)
|
||||
So(err.Error(), ShouldEqual, "Unsupported notification type")
|
||||
})
|
||||
|
||||
Convey("Read incorrect properties", func() {
|
||||
cfgProvifer := &configReader{log: log.New("test logger")}
|
||||
_, err := cfgProvifer.readConfig(incorrect_settings)
|
||||
cfgProvider := &configReader{log: log.New("test logger")}
|
||||
_, err := cfgProvider.readConfig(incorrect_settings)
|
||||
So(err, ShouldNotBeNil)
|
||||
So(err.Error(), ShouldEqual, "Alert validation error: Could not find url property in settings")
|
||||
})
|
||||
|
||||
@@ -154,7 +154,7 @@ func (val *StringMapValue) Value() map[string]string {
|
||||
return val.value
|
||||
}
|
||||
|
||||
// transformInterface tries to transform any interface type into proper value with env expansion. It travers maps and
|
||||
// transformInterface tries to transform any interface type into proper value with env expansion. It traverses maps and
|
||||
// slices and the actual interpolation is done on all simple string values in the structure. It returns a copy of any
|
||||
// map or slice value instead of modifying them in place and also return value without interpolation but with converted
|
||||
// type as a second value.
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
|
||||
func TestQuotaCommandsAndQueries(t *testing.T) {
|
||||
|
||||
Convey("Testing Qutoa commands & queries", t, func() {
|
||||
Convey("Testing Quota commands & queries", t, func() {
|
||||
InitTestDB(t)
|
||||
userId := int64(1)
|
||||
orgId := int64(0)
|
||||
|
||||
Reference in New Issue
Block a user