@@ -779,3 +779,213 @@ func TestRoundtrip_CustomZone(t *testing.T) {
779779 }
780780 }
781781}
782+
783+ func TestDeprecated (t * testing.T ) {
784+ for _ , tc := range []struct {
785+ name string
786+ deployment * akov2.AtlasDeployment
787+ wantDeprecated bool
788+ wantMsg string
789+ }{
790+ {
791+ name : "nil replication specs" ,
792+ deployment : & akov2.AtlasDeployment {
793+ Spec : akov2.AtlasDeploymentSpec {
794+ DeploymentSpec : & akov2.AdvancedDeploymentSpec {
795+ ReplicationSpecs : nil ,
796+ },
797+ },
798+ },
799+ },
800+ {
801+ name : "nil replication spec entries" ,
802+ deployment : & akov2.AtlasDeployment {
803+ Spec : akov2.AtlasDeploymentSpec {
804+ DeploymentSpec : & akov2.AdvancedDeploymentSpec {
805+ ReplicationSpecs : []* akov2.AdvancedReplicationSpec {
806+ nil , nil , nil ,
807+ },
808+ },
809+ },
810+ },
811+ },
812+ {
813+ name : "nil region configs" ,
814+ deployment : & akov2.AtlasDeployment {
815+ Spec : akov2.AtlasDeploymentSpec {
816+ DeploymentSpec : & akov2.AdvancedDeploymentSpec {
817+ ReplicationSpecs : []* akov2.AdvancedReplicationSpec {
818+ {
819+ RegionConfigs : nil ,
820+ },
821+ },
822+ },
823+ },
824+ },
825+ },
826+ {
827+ name : "nil region config entries" ,
828+ deployment : & akov2.AtlasDeployment {
829+ Spec : akov2.AtlasDeploymentSpec {
830+ DeploymentSpec : & akov2.AdvancedDeploymentSpec {
831+ ReplicationSpecs : []* akov2.AdvancedReplicationSpec {
832+ {
833+ RegionConfigs : []* akov2.AdvancedRegionConfig {
834+ nil , nil , nil ,
835+ },
836+ },
837+ },
838+ },
839+ },
840+ },
841+ },
842+ {
843+ name : "nil regionconfig specs" ,
844+ deployment : & akov2.AtlasDeployment {
845+ Spec : akov2.AtlasDeploymentSpec {
846+ DeploymentSpec : & akov2.AdvancedDeploymentSpec {
847+ ReplicationSpecs : []* akov2.AdvancedReplicationSpec {
848+ {
849+ RegionConfigs : []* akov2.AdvancedRegionConfig {
850+ {
851+ AnalyticsSpecs : nil ,
852+ ElectableSpecs : nil ,
853+ ReadOnlySpecs : nil ,
854+ },
855+ },
856+ },
857+ },
858+ },
859+ },
860+ },
861+ },
862+ {
863+ name : "empty regionconfig specs" ,
864+ deployment : & akov2.AtlasDeployment {
865+ Spec : akov2.AtlasDeploymentSpec {
866+ DeploymentSpec : & akov2.AdvancedDeploymentSpec {
867+ ReplicationSpecs : []* akov2.AdvancedReplicationSpec {
868+ {
869+ RegionConfigs : []* akov2.AdvancedRegionConfig {
870+ {
871+ AnalyticsSpecs : & akov2.Specs {},
872+ ElectableSpecs : & akov2.Specs {},
873+ ReadOnlySpecs : & akov2.Specs {},
874+ },
875+ },
876+ },
877+ },
878+ },
879+ },
880+ },
881+ },
882+ {
883+ name : "non deprecated M10 instance" ,
884+ deployment : & akov2.AtlasDeployment {
885+ Spec : akov2.AtlasDeploymentSpec {
886+ DeploymentSpec : & akov2.AdvancedDeploymentSpec {
887+ ReplicationSpecs : []* akov2.AdvancedReplicationSpec {
888+ {
889+ RegionConfigs : []* akov2.AdvancedRegionConfig {
890+ {
891+ AnalyticsSpecs : & akov2.Specs {
892+ InstanceSize : "M10" ,
893+ NodeCount : pointer .MakePtr (1 ),
894+ },
895+ ElectableSpecs : & akov2.Specs {
896+ InstanceSize : "M10" ,
897+ NodeCount : pointer .MakePtr (1 ),
898+ },
899+ ReadOnlySpecs : & akov2.Specs {
900+ InstanceSize : "M10" ,
901+ NodeCount : pointer .MakePtr (1 ),
902+ },
903+ },
904+ },
905+ },
906+ },
907+ },
908+ },
909+ },
910+ },
911+ {
912+ name : "deprecated M2 instance" ,
913+ deployment : & akov2.AtlasDeployment {
914+ Spec : akov2.AtlasDeploymentSpec {
915+ DeploymentSpec : & akov2.AdvancedDeploymentSpec {
916+ ReplicationSpecs : []* akov2.AdvancedReplicationSpec {
917+ {
918+ RegionConfigs : []* akov2.AdvancedRegionConfig {
919+ {
920+ AnalyticsSpecs : & akov2.Specs {
921+ InstanceSize : "M2" ,
922+ NodeCount : pointer .MakePtr (1 ),
923+ },
924+ ElectableSpecs : & akov2.Specs {
925+ InstanceSize : "M2" ,
926+ NodeCount : pointer .MakePtr (1 ),
927+ },
928+ ReadOnlySpecs : & akov2.Specs {
929+ InstanceSize : "M2" ,
930+ NodeCount : pointer .MakePtr (1 ),
931+ },
932+ },
933+ },
934+ },
935+ },
936+ },
937+ },
938+ },
939+ wantDeprecated : true ,
940+ wantMsg : "WARNING: M2 and M5 instance sizes are deprecated. See https://dochub.mongodb.org/core/atlas-flex-migration for details." ,
941+ },
942+ {
943+ name : "deprecated M2 instance" ,
944+ deployment : & akov2.AtlasDeployment {
945+ Spec : akov2.AtlasDeploymentSpec {
946+ DeploymentSpec : & akov2.AdvancedDeploymentSpec {
947+ ReplicationSpecs : []* akov2.AdvancedReplicationSpec {
948+ {
949+ RegionConfigs : []* akov2.AdvancedRegionConfig {
950+ {
951+ AnalyticsSpecs : & akov2.Specs {
952+ InstanceSize : "M5" ,
953+ NodeCount : pointer .MakePtr (1 ),
954+ },
955+ ElectableSpecs : & akov2.Specs {
956+ InstanceSize : "M5" ,
957+ NodeCount : pointer .MakePtr (1 ),
958+ },
959+ ReadOnlySpecs : & akov2.Specs {
960+ InstanceSize : "M5" ,
961+ NodeCount : pointer .MakePtr (1 ),
962+ },
963+ },
964+ },
965+ },
966+ },
967+ },
968+ },
969+ },
970+ wantDeprecated : true ,
971+ wantMsg : "WARNING: M2 and M5 instance sizes are deprecated. See https://dochub.mongodb.org/core/atlas-flex-migration for details." ,
972+ },
973+ {
974+ name : "empty serverless instance" ,
975+ deployment : & akov2.AtlasDeployment {
976+ Spec : akov2.AtlasDeploymentSpec {
977+ ServerlessSpec : & akov2.ServerlessSpec {},
978+ },
979+ },
980+ wantDeprecated : true ,
981+ wantMsg : "WARNING: Serverless is deprecated. See https://dochub.mongodb.org/core/atlas-flex-migration for details." ,
982+ },
983+ } {
984+ t .Run (tc .name , func (t * testing.T ) {
985+ d := NewDeployment ("123" , tc .deployment )
986+ gotDeprecated , gotMsg := d .Deprecated ()
987+ require .Equal (t , tc .wantDeprecated , gotDeprecated )
988+ require .Equal (t , tc .wantMsg , gotMsg )
989+ })
990+ }
991+ }
0 commit comments