Skip to content
This repository was archived by the owner on May 31, 2024. It is now read-only.

Commit 29da288

Browse files
authored
Add support for gate nodes (#399)
* Add support for gate nodes Signed-off-by: eduardo apolinario <eapolinario@users.noreply.github.com> * Linting Signed-off-by: eduardo apolinario <eapolinario@users.noreply.github.com> --------- Signed-off-by: eduardo apolinario <eapolinario@users.noreply.github.com> Co-authored-by: eduardo apolinario <eapolinario@users.noreply.github.com>
1 parent e55c649 commit 29da288

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

cmd/register/register_util.go

+2
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ func hydrateNode(node *core.Node, version string, force bool) error {
245245
default:
246246
return fmt.Errorf("unknown type %T", branchNodeWrapper.BranchNode.IfElse.Default)
247247
}
248+
case *core.Node_GateNode:
249+
// Do nothing.
248250
default:
249251
return fmt.Errorf("unknown type %T", v)
250252
}

cmd/register/register_util_test.go

+59
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
"github.com/stretchr/testify/mock"
3636
"google.golang.org/grpc/codes"
3737
"google.golang.org/grpc/status"
38+
"google.golang.org/protobuf/types/known/durationpb"
3839
)
3940

4041
type MockHTTPClient struct {
@@ -501,6 +502,64 @@ func TestHydrateNode(t *testing.T) {
501502
})
502503
}
503504

505+
func TestHydrateGateNode(t *testing.T) {
506+
t.Run("Hydrate Sleep", func(t *testing.T) {
507+
registerFilesSetup()
508+
// Write a node that contains a GateNode
509+
node := &core.Node{
510+
Target: &core.Node_GateNode{
511+
GateNode: &core.GateNode{
512+
Condition: &core.GateNode_Sleep{
513+
Sleep: &core.SleepCondition{
514+
Duration: &durationpb.Duration{
515+
Seconds: 10,
516+
},
517+
},
518+
},
519+
},
520+
},
521+
}
522+
err := hydrateNode(node, rconfig.DefaultFilesConfig.Version, true)
523+
assert.Nil(t, err)
524+
})
525+
526+
t.Run("Hydrate Signal", func(t *testing.T) {
527+
registerFilesSetup()
528+
// Write a node that contains a GateNode
529+
node := &core.Node{
530+
Target: &core.Node_GateNode{
531+
GateNode: &core.GateNode{
532+
Condition: &core.GateNode_Signal{
533+
Signal: &core.SignalCondition{
534+
SignalId: "abc",
535+
},
536+
},
537+
},
538+
},
539+
}
540+
err := hydrateNode(node, rconfig.DefaultFilesConfig.Version, true)
541+
assert.Nil(t, err)
542+
})
543+
544+
t.Run("Hydrate Approve", func(t *testing.T) {
545+
registerFilesSetup()
546+
// Write a node that contains a GateNode
547+
node := &core.Node{
548+
Target: &core.Node_GateNode{
549+
GateNode: &core.GateNode{
550+
Condition: &core.GateNode_Approve{
551+
Approve: &core.ApproveCondition{
552+
SignalId: "abc",
553+
},
554+
},
555+
},
556+
},
557+
}
558+
err := hydrateNode(node, rconfig.DefaultFilesConfig.Version, true)
559+
assert.Nil(t, err)
560+
})
561+
}
562+
504563
func TestHydrateTaskSpec(t *testing.T) {
505564
testScope := promutils.NewTestScope()
506565
labeled.SetMetricKeys(contextutils.AppNameKey, contextutils.ProjectKey, contextutils.DomainKey)

0 commit comments

Comments
 (0)