evaluator

package
Version: v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Evaluate = func(context *models.EvalContext, mock *om.Mock) (response models.MockEvalResponse, err error) {
	actions_performed := &[]*models.ActionPerformed{}

	expect_passed := checkChannelCondition(context, mock)
	if !expect_passed {
		return models.MockEvalResponse{
			ExpectPassed:     false,
			ActionsPerformed: *actions_performed,
		}, nil
	}

	om_context, err := conditionContext(context)
	if err != nil {
		logrus.Errorf("Problem setting up om context %v", err)
		return models.MockEvalResponse{
			ExpectPassed:     true,
			ActionsPerformed: *actions_performed,
		}, err
	}
	if om_context != nil {
		om_context.Values = mock.Values
	}

	condition_passed, condition_rendered, err := checkCondition(context, mock, om_context)
	if err != nil {
		return models.MockEvalResponse{
			ExpectPassed:     true,
			ActionsPerformed: *actions_performed,
		}, err
	}
	if !condition_passed {
		return models.MockEvalResponse{
			ExpectPassed:      true,
			ActionsPerformed:  *actions_performed,
			ConditionRendered: condition_rendered,
		}, nil
	}

	if mock != nil {
		actions_performed, err = actionsPerformed(om_context, &mock.Actions)
		if err != nil {
			return models.MockEvalResponse{
				ExpectPassed:      true,
				ActionsPerformed:  *actions_performed,
				ConditionRendered: condition_rendered,
			}, err
		}
	}

	return models.MockEvalResponse{
		ExpectPassed:      expect_passed,
		ActionsPerformed:  *actions_performed,
		ConditionPassed:   condition_passed,
		ConditionRendered: condition_rendered,
	}, nil
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL