Fix broken tests, typos
This commit is contained in:
@@ -165,8 +165,6 @@ mocks: $(MOCKGEN)
|
||||
$(MOCKGEN) -package repository -source system/repository/user.go -destination system/repository/mocks/user.go
|
||||
$(MOCKGEN) -package repository -source system/repository/credentials.go -destination system/repository/mocks/credentials.go
|
||||
|
||||
$(MOCKGEN) -package service_mocks -source compose/service/automation_runner.go -destination compose/service/mocks/automation_runner.go
|
||||
|
||||
$(MOCKGEN) -package mail -source pkg/mail/mail.go -destination pkg/mail/mail_mock_test.go
|
||||
|
||||
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: compose/service/automation_runner.go
|
||||
|
||||
// Package service_mocks is a generated GoMock package.
|
||||
package service_mocks
|
||||
|
||||
import (
|
||||
context "context"
|
||||
automation "github.com/cortezaproject/corteza-server/pkg/automation"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
reflect "reflect"
|
||||
)
|
||||
|
||||
// MockautomationScriptsFinder is a mock of automationScriptsFinder interface
|
||||
type MockautomationScriptsFinder struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockautomationScriptsFinderMockRecorder
|
||||
}
|
||||
|
||||
// MockautomationScriptsFinderMockRecorder is the mock recorder for MockautomationScriptsFinder
|
||||
type MockautomationScriptsFinderMockRecorder struct {
|
||||
mock *MockautomationScriptsFinder
|
||||
}
|
||||
|
||||
// NewMockautomationScriptsFinder creates a new mock instance
|
||||
func NewMockautomationScriptsFinder(ctrl *gomock.Controller) *MockautomationScriptsFinder {
|
||||
mock := &MockautomationScriptsFinder{ctrl: ctrl}
|
||||
mock.recorder = &MockautomationScriptsFinderMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use
|
||||
func (m *MockautomationScriptsFinder) EXPECT() *MockautomationScriptsFinderMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Watch mocks base method
|
||||
func (m *MockautomationScriptsFinder) Watch(ctx context.Context) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "Watch", ctx)
|
||||
}
|
||||
|
||||
// Watch indicates an expected call of Watch
|
||||
func (mr *MockautomationScriptsFinderMockRecorder) Watch(ctx interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Watch", reflect.TypeOf((*MockautomationScriptsFinder)(nil).Watch), ctx)
|
||||
}
|
||||
|
||||
// WatchScheduled mocks base method
|
||||
func (m *MockautomationScriptsFinder) WatchScheduled(ctx context.Context, runner automation.DeferredAutomationRunner) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "WatchScheduled", ctx, runner)
|
||||
}
|
||||
|
||||
// WatchScheduled indicates an expected call of WatchScheduled
|
||||
func (mr *MockautomationScriptsFinderMockRecorder) WatchScheduled(ctx, runner interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WatchScheduled", reflect.TypeOf((*MockautomationScriptsFinder)(nil).WatchScheduled), ctx, runner)
|
||||
}
|
||||
|
||||
// FindRunnableScripts mocks base method
|
||||
func (m *MockautomationScriptsFinder) FindRunnableScripts(resource, event string, cc ...automation.TriggerConditionChecker) automation.ScriptSet {
|
||||
m.ctrl.T.Helper()
|
||||
varargs := []interface{}{resource, event}
|
||||
for _, a := range cc {
|
||||
varargs = append(varargs, a)
|
||||
}
|
||||
ret := m.ctrl.Call(m, "FindRunnableScripts", varargs...)
|
||||
ret0, _ := ret[0].(automation.ScriptSet)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// FindRunnableScripts indicates an expected call of FindRunnableScripts
|
||||
func (mr *MockautomationScriptsFinderMockRecorder) FindRunnableScripts(resource, event interface{}, cc ...interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
varargs := append([]interface{}{resource, event}, cc...)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindRunnableScripts", reflect.TypeOf((*MockautomationScriptsFinder)(nil).FindRunnableScripts), varargs...)
|
||||
}
|
||||
|
||||
// MockautomationRunnerAccessControler is a mock of automationRunnerAccessControler interface
|
||||
type MockautomationRunnerAccessControler struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockautomationRunnerAccessControlerMockRecorder
|
||||
}
|
||||
|
||||
// MockautomationRunnerAccessControlerMockRecorder is the mock recorder for MockautomationRunnerAccessControler
|
||||
type MockautomationRunnerAccessControlerMockRecorder struct {
|
||||
mock *MockautomationRunnerAccessControler
|
||||
}
|
||||
|
||||
// NewMockautomationRunnerAccessControler creates a new mock instance
|
||||
func NewMockautomationRunnerAccessControler(ctrl *gomock.Controller) *MockautomationRunnerAccessControler {
|
||||
mock := &MockautomationRunnerAccessControler{ctrl: ctrl}
|
||||
mock.recorder = &MockautomationRunnerAccessControlerMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use
|
||||
func (m *MockautomationRunnerAccessControler) EXPECT() *MockautomationRunnerAccessControlerMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// CanRunAutomationTrigger mocks base method
|
||||
func (m *MockautomationRunnerAccessControler) CanRunAutomationTrigger(ctx context.Context, r *automation.Trigger) bool {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "CanRunAutomationTrigger", ctx, r)
|
||||
ret0, _ := ret[0].(bool)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// CanRunAutomationTrigger indicates an expected call of CanRunAutomationTrigger
|
||||
func (mr *MockautomationRunnerAccessControlerMockRecorder) CanRunAutomationTrigger(ctx, r interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CanRunAutomationTrigger", reflect.TypeOf((*MockautomationRunnerAccessControler)(nil).CanRunAutomationTrigger), ctx, r)
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package corredor
|
||||
|
||||
import (
|
||||
"github.com/cortezaproject/corteza-server/pkg/app/options"
|
||||
"github.com/cortezaproject/corteza-server/pkg/eventbus"
|
||||
"go.uber.org/zap"
|
||||
"testing"
|
||||
|
||||
@@ -12,7 +13,7 @@ type (
|
||||
mockEvent struct {
|
||||
rType string
|
||||
eType string
|
||||
match func(name string, op string, values ...string) bool
|
||||
match func(matcher eventbus.ConstraintMatcher) bool
|
||||
}
|
||||
)
|
||||
|
||||
@@ -32,12 +33,12 @@ func (e mockEvent) Decode(map[string][]byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e mockEvent) Match(name string, op string, values ...string) bool {
|
||||
func (e mockEvent) Match(matcher eventbus.ConstraintMatcher) bool {
|
||||
if e.match == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
return e.match(name, op, values...)
|
||||
return e.match(matcher)
|
||||
}
|
||||
|
||||
func TestFindOnManual(t *testing.T) {
|
||||
@@ -47,24 +48,24 @@ func TestFindOnManual(t *testing.T) {
|
||||
&Script{
|
||||
Triggers: []*Trigger{
|
||||
&Trigger{
|
||||
Events: []string{"ev"},
|
||||
Resources: []string{"res"},
|
||||
EventTypes: []string{"ev"},
|
||||
ResourceTypes: []string{"res"},
|
||||
},
|
||||
},
|
||||
},
|
||||
&Script{
|
||||
Triggers: []*Trigger{
|
||||
&Trigger{
|
||||
Events: []string{"foo"},
|
||||
Resources: []string{"bar"},
|
||||
EventTypes: []string{"foo"},
|
||||
ResourceTypes: []string{"bar"},
|
||||
},
|
||||
},
|
||||
},
|
||||
//&Script{
|
||||
// Triggers: []*Trigger{
|
||||
// &Trigger{
|
||||
// Events: []string{"not-a-match"},
|
||||
// Resources: []string{"not-a-match"},
|
||||
// EventTypes: []string{"not-a-match"},
|
||||
// ResourceTypes: []string{"not-a-match"},
|
||||
// },
|
||||
// },
|
||||
//},
|
||||
@@ -73,16 +74,16 @@ func TestFindOnManual(t *testing.T) {
|
||||
&Script{
|
||||
Triggers: []*Trigger{
|
||||
&Trigger{
|
||||
Events: []string{"ev"},
|
||||
Resources: []string{"res"},
|
||||
EventTypes: []string{"ev"},
|
||||
ResourceTypes: []string{"res"},
|
||||
},
|
||||
},
|
||||
},
|
||||
&Script{
|
||||
Triggers: []*Trigger{
|
||||
&Trigger{
|
||||
Events: []string{"foo"},
|
||||
Resources: []string{"bar"},
|
||||
EventTypes: []string{"foo"},
|
||||
ResourceTypes: []string{"bar"},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
+19
-19
@@ -12,15 +12,15 @@ func TestPopOnManualEventType(t *testing.T) {
|
||||
a = assert.New(t)
|
||||
|
||||
trg = &Trigger{
|
||||
Events: []string{"onTimestamp", onManualEventType, "onInterval"},
|
||||
EventTypes: []string{"onTimestamp", onManualEventType, "onInterval"},
|
||||
}
|
||||
)
|
||||
|
||||
a.Len(trg.Events, 3)
|
||||
a.Len(trg.EventTypes, 3)
|
||||
a.True(popOnManualEventType(trg))
|
||||
a.Len(trg.Events, 2)
|
||||
a.Len(trg.EventTypes, 2)
|
||||
a.False(popOnManualEventType(trg))
|
||||
a.Len(trg.Events, 2)
|
||||
a.Len(trg.EventTypes, 2)
|
||||
}
|
||||
|
||||
func TestPluckManualTriggers(t *testing.T) {
|
||||
@@ -29,14 +29,14 @@ func TestPluckManualTriggers(t *testing.T) {
|
||||
|
||||
s = &ServerScript{
|
||||
Triggers: []*Trigger{&Trigger{
|
||||
Resources: []string{"r1", "r2"},
|
||||
Events: []string{"onTimestamp", onManualEventType, "onInterval"},
|
||||
RunAs: "moi",
|
||||
ResourceTypes: []string{"r1", "r2"},
|
||||
EventTypes: []string{"onTimestamp", onManualEventType, "onInterval"},
|
||||
RunAs: "moi",
|
||||
}},
|
||||
}
|
||||
)
|
||||
|
||||
a.Len(s.Triggers[0].Events, 3)
|
||||
a.Len(s.Triggers[0].EventTypes, 3)
|
||||
a.EqualValues(
|
||||
map[string]string{
|
||||
"r1": "moi",
|
||||
@@ -44,7 +44,7 @@ func TestPluckManualTriggers(t *testing.T) {
|
||||
},
|
||||
pluckManualTriggers(s),
|
||||
)
|
||||
a.Len(s.Triggers[0].Events, 2)
|
||||
a.Len(s.Triggers[0].EventTypes, 2)
|
||||
|
||||
// Running again must result in empty hash
|
||||
a.EqualValues(
|
||||
@@ -58,8 +58,8 @@ func TestTriggerOptsMaking(t *testing.T) {
|
||||
a = assert.New(t)
|
||||
|
||||
trg = &Trigger{
|
||||
Resources: []string{"r1", "r2"},
|
||||
Events: []string{"onTimestamp", onManualEventType, "onInterval"},
|
||||
ResourceTypes: []string{"r1", "r2"},
|
||||
EventTypes: []string{"onTimestamp", onManualEventType, "onInterval"},
|
||||
Constraints: []*TConstraint{
|
||||
&TConstraint{Name: "some1", Op: "eq", Value: []string{"other"}},
|
||||
&TConstraint{Name: "some2", Op: "eq", Value: []string{"other"}},
|
||||
@@ -74,10 +74,10 @@ func TestTriggerOptsMaking(t *testing.T) {
|
||||
a.NoError(err)
|
||||
a.Len(oo, 4) // 1x all resources, 1x all events, 2x constraints
|
||||
|
||||
oo, err = makeTriggerOpts(&Trigger{Resources: []string{"bar"}})
|
||||
oo, err = makeTriggerOpts(&Trigger{ResourceTypes: []string{"bar"}})
|
||||
a.Error(err, "expecting to fail on trigger w/o events")
|
||||
|
||||
oo, err = makeTriggerOpts(&Trigger{Events: []string{"foo"}})
|
||||
oo, err = makeTriggerOpts(&Trigger{EventTypes: []string{"foo"}})
|
||||
a.Error(err, "expecting to fail on trigger w/o resources")
|
||||
}
|
||||
|
||||
@@ -107,8 +107,8 @@ func TestScriptFilterMaker(t *testing.T) {
|
||||
s1 = &Script{
|
||||
Triggers: []*Trigger{
|
||||
&Trigger{
|
||||
Events: []string{"ev"},
|
||||
Resources: []string{"res"},
|
||||
EventTypes: []string{"ev"},
|
||||
ResourceTypes: []string{"res"},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -116,8 +116,8 @@ func TestScriptFilterMaker(t *testing.T) {
|
||||
s2 = &Script{
|
||||
Triggers: []*Trigger{
|
||||
&Trigger{
|
||||
Events: []string{"foo"},
|
||||
Resources: []string{"bar"},
|
||||
EventTypes: []string{"foo"},
|
||||
ResourceTypes: []string{"bar"},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -125,8 +125,8 @@ func TestScriptFilterMaker(t *testing.T) {
|
||||
s3 = &Script{
|
||||
Triggers: []*Trigger{
|
||||
&Trigger{
|
||||
Events: []string{"not-a-match"},
|
||||
Resources: []string{"not-a-match"},
|
||||
EventTypes: []string{"not-a-match"},
|
||||
ResourceTypes: []string{"not-a-match"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ func (set RuleSet) checkResource(res Resource, op Operation, roles ...uint64) (v
|
||||
}
|
||||
|
||||
if res.IsAppendable() {
|
||||
// Is this a specific resource and can we turn it ito a wildcarded-resource?
|
||||
// Is this a specific resource and can we turn it into a wild-carded resource?
|
||||
if v = set.check(res.AppendWildcard(), op, roles...); v != Inherit {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ type (
|
||||
mockEvent struct {
|
||||
rType string
|
||||
eType string
|
||||
match func(name string, op string, values ...string) bool
|
||||
match func(matcher eventbus.ConstraintMatcher) bool
|
||||
}
|
||||
)
|
||||
|
||||
@@ -27,12 +27,12 @@ func (e mockEvent) EventType() string {
|
||||
return e.eType
|
||||
}
|
||||
|
||||
func (e mockEvent) Match(name string, op string, values ...string) bool {
|
||||
func (e mockEvent) Match(matcher eventbus.ConstraintMatcher) bool {
|
||||
if e.match == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
return e.match(name, op, values...)
|
||||
return e.match(matcher)
|
||||
}
|
||||
|
||||
func TestMainServiceFunctions(t *testing.T) {
|
||||
|
||||
@@ -26,7 +26,8 @@ Message-ID: <1234@local.machine.example>
|
||||
Ola Corteza!
|
||||
`,
|
||||
wantOut: &MailMessage{
|
||||
Date: time.Time{},
|
||||
Date: time.Time{},
|
||||
Subject: "Customer service contact info",
|
||||
Header: MailMessageHeader{
|
||||
From: []*mail.Address{{Address: "sender@testing.cortezaproject.org"}},
|
||||
To: []*mail.Address{{Address: "rcpt@testing.cortezaproject.org"}},
|
||||
|
||||
Reference in New Issue
Block a user