Skip to content

Commit

Permalink
update package tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Singer committed Mar 12, 2024
1 parent 61e89c9 commit 9a08362
Show file tree
Hide file tree
Showing 12 changed files with 608 additions and 51 deletions.
18 changes: 9 additions & 9 deletions pkg/engine/operational_eval/dependency_capture_mock_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions pkg/engine/operational_eval/evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,6 @@ func (eval *Evaluator) enqueue(changes graphChanges) error {
errs = errors.Join(errs, fmt.Errorf("could not get existing vertex %s: %w", key, err))
continue
}
if v.Key().keyType() == keyTypeEdge {
fmt.Println("test")
}
if v != existing {
existing.UpdateFrom(v)
}
Expand Down
15 changes: 8 additions & 7 deletions pkg/engine/operational_eval/operational_rule_mock_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions pkg/engine/operational_eval/vertex_edge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@ func Test_edgeVertex_Dependencies(t *testing.T) {
Source: construct.ResourceId{Name: "source"},
Target: construct.ResourceId{Name: "target"},
},
Rules: []knowledgebase.OperationalRule{
{
Rules: map[string]knowledgebase.OperationalRule{
"1": {
If: "First",
},
{
"2": {
If: "Second",
},
},
},
mocks: func(dcap *MockdependencyCapturer, v *edgeVertex) {
dcap.EXPECT().ExecuteOpRule(knowledgebase.DynamicValueData{
Edge: &construct.Edge{Source: v.Edge.Source, Target: v.Edge.Target},
}, v.Rules[0]).Times(1)
}, v.Rules["1"]).Times(1)
dcap.EXPECT().ExecuteOpRule(knowledgebase.DynamicValueData{
Edge: &construct.Edge{Source: v.Edge.Source, Target: v.Edge.Target},
}, v.Rules[1]).Times(1)
}, v.Rules["2"]).Times(1)
dcap.EXPECT().GetChanges().Times(1)
},
},
Expand Down
3 changes: 2 additions & 1 deletion pkg/engine/operational_eval/vertex_property_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
construct "github.com/klothoplatform/klotho/pkg/construct"
"github.com/klothoplatform/klotho/pkg/engine/constraints"
"github.com/klothoplatform/klotho/pkg/engine/enginetesting"
operational_rule "github.com/klothoplatform/klotho/pkg/engine/operational_rule"
knowledgebase "github.com/klothoplatform/klotho/pkg/knowledgebase"
"github.com/klothoplatform/klotho/pkg/knowledgebase/properties"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -188,7 +189,7 @@ func Test_propertyVertex_evaluateEdgeOperational(t *testing.T) {
Resource: tt.args.v.Ref.Resource,
Edge: &graph.Edge[construct.ResourceId]{Source: construct.ResourceId{Name: "test"}, Target: construct.ResourceId{Name: "test2"}},
}).Times(1)
opctx.EXPECT().HandleOperationalRule(rule).Return(nil).Times(1)
opctx.EXPECT().HandleOperationalRule(rule, operational_rule.AddConfiguruationOperator).Return(nil).Times(1)
err := tt.args.v.evaluateEdgeOperational(tt.args.res, opctx)
if tt.wantErr {
assert.Error(err)
Expand Down
5 changes: 3 additions & 2 deletions pkg/engine/operational_eval/vertex_resource_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"

construct "github.com/klothoplatform/klotho/pkg/construct"
"github.com/klothoplatform/klotho/pkg/engine/operational_rule"
knowledgebase "github.com/klothoplatform/klotho/pkg/knowledgebase"
"github.com/stretchr/testify/assert"
gomock "go.uber.org/mock/gomock"
Expand Down Expand Up @@ -151,7 +152,7 @@ func Test_resourceRuleVertex_evaluateResourceRule(t *testing.T) {
mocks: func() {
opctx.EXPECT().HandleOperationalRule(knowledgebase.OperationalRule{
If: "test",
}).Return(nil)
}, operational_rule.AddConfiguruationOperator).Return(nil)
},
},
{
Expand All @@ -165,7 +166,7 @@ func Test_resourceRuleVertex_evaluateResourceRule(t *testing.T) {
mocks: func() {
opctx.EXPECT().HandleOperationalRule(knowledgebase.OperationalRule{
If: "test",
}).Return(fmt.Errorf("err"))
}, operational_rule.AddConfiguruationOperator).Return(fmt.Errorf("err"))
},
wantErr: true,
},
Expand Down
Loading

0 comments on commit 9a08362

Please sign in to comment.