Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
feat: strip annotation tests
Browse files Browse the repository at this point in the history
Signed-off-by: Kenny Workman <kennyworkman@sbcglobal.net>
  • Loading branch information
kennyworkman committed Dec 2, 2021
1 parent 8afd019 commit 43a557e
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions pkg/compiler/transformers/k8s/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"testing"

"github.com/flyteorg/flytepropeller/pkg/apis/flyteworkflow/v1alpha1"
"google.golang.org/protobuf/types/known/structpb"
"k8s.io/apimachinery/pkg/api/resource"

"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/core"
Expand Down Expand Up @@ -209,3 +210,59 @@ func TestBuildNodeSpec(t *testing.T) {
})

}

func TestBuildTasks(t *testing.T) {

withoutAnnotations := make(map[string]*core.Variable)
withoutAnnotations["a"] = &core.Variable{
Type: &core.LiteralType{
Annotation: &core.TypeAnnotation{},
},
}

randomData, _ := structpb.NewStruct(map[string]interface{}{
"foo": "bar",
})

withAnnotations := make(map[string]*core.Variable)
withAnnotations["a"] = &core.Variable{
Type: &core.LiteralType{
Annotation: &core.TypeAnnotation{Annotations: randomData},
},
}

tasks := []*core.CompiledTask{
{
Template: &core.TaskTemplate{
Id: &core.Identifier{Name: "annotated"},
Interface: &core.TypedInterface{
Inputs: &core.VariableMap{
Variables: withAnnotations,
},
},
},
},
{
Template: &core.TaskTemplate{
Id: &core.Identifier{Name: "unannotated"},
Interface: &core.TypedInterface{
Inputs: &core.VariableMap{
Variables: withoutAnnotations,
},
},
},
},
}

errs := errors.NewCompileErrors()

t.Run("Tasks with annotations", func(t *testing.T) {
taskMap := buildTasks(tasks, errs)

annTask := taskMap[(&core.Identifier{Name: "annotated"}).String()]
assert.Nil(t, annTask.Interface.Inputs.Variables["a"].Type.Annotation)

unAnnTask := taskMap[(&core.Identifier{Name: "annotated"}).String()]
assert.Nil(t, unAnnTask.Interface.Inputs.Variables["a"].Type.Annotation)
})
}

0 comments on commit 43a557e

Please sign in to comment.