@@ -21,6 +21,7 @@ import (
2121
2222 ackcompare "github.com/aws-controllers-k8s/runtime/pkg/compare"
2323 "github.com/aws/aws-sdk-go-v2/aws"
24+ "github.com/aws/aws-sdk-go-v2/service/eks"
2425 svcsdktypes "github.com/aws/aws-sdk-go-v2/service/eks/types"
2526 "github.com/stretchr/testify/assert"
2627 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -551,6 +552,99 @@ func Test_newUpdateNodegroupPayload(t *testing.T) {
551552 }
552553}
553554
555+ func Test_newUpdateNodegroupPayloadWithLaunchTemplate (t * testing.T ) {
556+ delta := ackcompare .NewDelta ()
557+ delta .Add ("Spec.Version" , nil , nil )
558+ delta .Add ("Spec.LaunchTemplate" , nil , nil )
559+
560+ type args struct {
561+ r * resource
562+ }
563+ tests := []struct {
564+ name string
565+ args args
566+ wantPayload * eks.UpdateNodegroupVersionInput
567+ }{
568+ {
569+ name : "only id in launch template" ,
570+ args : args {
571+ r : & resource {
572+ ko : & v1alpha1.Nodegroup {
573+ Spec : v1alpha1.NodegroupSpec {
574+ LaunchTemplate : & v1alpha1.LaunchTemplateSpecification {
575+ ID : aws .String ("lt-12345" ),
576+ Version : aws .String ("1" ),
577+ },
578+ },
579+ },
580+ },
581+ },
582+ wantPayload : & eks.UpdateNodegroupVersionInput {
583+ ClusterName : nil ,
584+ NodegroupName : nil ,
585+ LaunchTemplate : & svcsdktypes.LaunchTemplateSpecification {
586+ Id : aws .String ("lt-12345" ),
587+ Version : aws .String ("1" ),
588+ },
589+ },
590+ },
591+ {
592+ name : "only name in launch template" ,
593+ args : args {
594+ r : & resource {
595+ ko : & v1alpha1.Nodegroup {
596+ Spec : v1alpha1.NodegroupSpec {
597+ LaunchTemplate : & v1alpha1.LaunchTemplateSpecification {
598+ Name : aws .String ("my-launch-template" ),
599+ Version : aws .String ("1" ),
600+ },
601+ },
602+ },
603+ },
604+ },
605+ wantPayload : & eks.UpdateNodegroupVersionInput {
606+ ClusterName : nil ,
607+ NodegroupName : nil ,
608+ LaunchTemplate : & svcsdktypes.LaunchTemplateSpecification {
609+ Name : aws .String ("my-launch-template" ),
610+ Version : aws .String ("1" ),
611+ },
612+ },
613+ },
614+ {
615+ name : "id and name in launch template" ,
616+ args : args {
617+ r : & resource {
618+ ko : & v1alpha1.Nodegroup {
619+ Spec : v1alpha1.NodegroupSpec {
620+ LaunchTemplate : & v1alpha1.LaunchTemplateSpecification {
621+ ID : aws .String ("lt-12345" ),
622+ Name : aws .String ("my-launch-template" ),
623+ Version : aws .String ("1" ),
624+ },
625+ },
626+ },
627+ },
628+ },
629+ wantPayload : & eks.UpdateNodegroupVersionInput {
630+ ClusterName : nil ,
631+ NodegroupName : nil ,
632+ LaunchTemplate : & svcsdktypes.LaunchTemplateSpecification {
633+ Id : aws .String ("lt-12345" ),
634+ Version : aws .String ("1" ),
635+ },
636+ },
637+ },
638+ }
639+
640+ for _ , tt := range tests {
641+ t .Run (tt .name , func (t * testing.T ) {
642+ got := newUpdateNodegroupVersionPayload (delta , tt .args .r )
643+ assert .Equal (t , tt .wantPayload , got )
644+ })
645+ }
646+ }
647+
554648func Test_AMITypeBottlerocket (t * testing.T ) {
555649 tests := []struct {
556650 name string
0 commit comments