@@ -692,14 +692,14 @@ func TestIsCheckpointsV2Enabled_True(t *testing.T) {
692692 }
693693}
694694
695- func TestIsCheckpointsV2Enabled_V2Only (t * testing.T ) {
695+ func TestIsCheckpointsV2Enabled_CheckpointsVersion2 (t * testing.T ) {
696696 t .Parallel ()
697697 s := & EntireSettings {
698698 Enabled : true ,
699- StrategyOptions : map [string ]any {"checkpoints_v2_only " : true },
699+ StrategyOptions : map [string ]any {"checkpoints_version " : 2 },
700700 }
701701 if ! s .IsCheckpointsV2Enabled () {
702- t .Error ("expected IsCheckpointsV2Enabled to be true when checkpoints_v2_only is enabled " )
702+ t .Error ("expected IsCheckpointsV2Enabled to be true when checkpoints_version is 2 " )
703703 }
704704}
705705
@@ -788,33 +788,34 @@ func TestIsCheckpointsV2Enabled_LocalOverride(t *testing.T) {
788788 }
789789}
790790
791- func TestIsCheckpointsV2OnlyEnabled_DefaultsFalse (t * testing.T ) {
791+ func TestCheckpointsVersion (t * testing.T ) {
792792 t .Parallel ()
793- s := & EntireSettings {Enabled : true }
794- if s .IsCheckpointsV2OnlyEnabled () {
795- t .Error ("expected IsCheckpointsV2OnlyEnabled to default to false" )
796- }
797- }
798793
799- func TestIsCheckpointsV2OnlyEnabled_True (t * testing.T ) {
800- t .Parallel ()
801- s := & EntireSettings {
802- Enabled : true ,
803- StrategyOptions : map [string ]any {"checkpoints_v2_only" : true },
804- }
805- if ! s .IsCheckpointsV2OnlyEnabled () {
806- t .Error ("expected IsCheckpointsV2OnlyEnabled to be true" )
794+ tests := []struct {
795+ name string
796+ opts map [string ]any
797+ want int
798+ }{
799+ {"unset defaults to one" , nil , 1 },
800+ {"empty options defaults to one" , map [string ]any {}, 1 },
801+ {"integer 2" , map [string ]any {"checkpoints_version" : 2 }, 2 },
802+ {"float 2 from json" , map [string ]any {"checkpoints_version" : float64 (2 )}, 2 },
803+ {"integer 3 falls back to default" , map [string ]any {"checkpoints_version" : 3 }, 1 },
804+ {"zero falls back to default" , map [string ]any {"checkpoints_version" : 0 }, 1 },
805+ {"negative falls back to default" , map [string ]any {"checkpoints_version" : - 1 }, 1 },
806+ {"non-integer float falls back to default" , map [string ]any {"checkpoints_version" : 2.5 }, 1 },
807+ {"string 2" , map [string ]any {"checkpoints_version" : "2" }, 2 },
808+ {"bool falls back to default" , map [string ]any {"checkpoints_version" : true }, 1 },
807809 }
808- }
809810
810- func TestIsCheckpointsV2OnlyEnabled_WrongType ( t * testing. T ) {
811- t . Parallel ()
812- s := & EntireSettings {
813- Enabled : true ,
814- StrategyOptions : map [ string ] any { "checkpoints_v2_only" : "yes" },
815- }
816- if s . IsCheckpointsV2OnlyEnabled () {
817- t . Error ( "expected IsCheckpointsV2OnlyEnabled to be false for non-bool value" )
811+ for _ , tt := range tests {
812+ t . Run ( tt . name , func ( t * testing. T ) {
813+ t . Parallel ()
814+ s := & EntireSettings { StrategyOptions : tt . opts }
815+ if got := s . CheckpointsVersion (); got != tt . want {
816+ t . Errorf ( "CheckpointsVersion() = %d, want %d" , got , tt . want )
817+ }
818+ } )
818819 }
819820}
820821
@@ -834,7 +835,7 @@ func TestIsPushV2RefsEnabled_RequiresBothFlags(t *testing.T) {
834835 opts map [string ]any
835836 expected bool
836837 }{
837- {"v2 only supersedes both" , map [string ]any {"checkpoints_v2" : false , "push_v2_refs" : false , "checkpoints_v2_only " : true }, true },
838+ {"checkpoints_version 2 supersedes both" , map [string ]any {"checkpoints_v2" : false , "push_v2_refs" : false , "checkpoints_version " : 2 }, true },
838839 {"both true" , map [string ]any {"checkpoints_v2" : true , "push_v2_refs" : true }, true },
839840 {"only checkpoints_v2" , map [string ]any {"checkpoints_v2" : true }, false },
840841 {"only push_v2_refs" , map [string ]any {"push_v2_refs" : true }, false },
0 commit comments