@@ -817,6 +817,48 @@ func TestSaveDeltaErrorsWhenProjectDirHasNoDotGradle(t *testing.T) {
817817 }
818818}
819819
820+ func TestSaveDeltaSkipsColdStartBeforeProjectDirValidation (t * testing.T ) {
821+ ctx := context .Background ()
822+ gradleHome := t .TempDir ()
823+ must (t , os .MkdirAll (filepath .Join (gradleHome , "caches" ), 0o755 ))
824+
825+ projectDir := t .TempDir ()
826+ err := SaveDelta (ctx , SaveDeltaConfig {
827+ CachewURL : "http://example.invalid" ,
828+ CacheKey : "test-cache" ,
829+ Branch : "feature/test" ,
830+ GradleUserHome : gradleHome ,
831+ ProjectDir : projectDir ,
832+ })
833+ if err != nil {
834+ t .Fatalf ("expected cold-start SaveDelta to skip without validating project dir, got %v" , err )
835+ }
836+ }
837+
838+ func TestSaveDeltaReturnsMarkerStatErrors (t * testing.T ) {
839+ ctx := context .Background ()
840+ root := t .TempDir ()
841+ gradleHome := filepath .Join (root , "gradle-home-file" )
842+ must (t , os .WriteFile (gradleHome , []byte ("not a directory" ), 0o644 ))
843+
844+ projectDir := t .TempDir ()
845+ must (t , os .MkdirAll (filepath .Join (projectDir , ".gradle" ), 0o755 ))
846+
847+ err := SaveDelta (ctx , SaveDeltaConfig {
848+ CachewURL : "http://example.invalid" ,
849+ CacheKey : "test-cache" ,
850+ Branch : "feature/test" ,
851+ GradleUserHome : gradleHome ,
852+ ProjectDir : projectDir ,
853+ })
854+ if err == nil {
855+ t .Fatal ("expected SaveDelta to return non-not-exist restore marker stat errors" )
856+ }
857+ if ! strings .Contains (err .Error (), "stat restore marker" ) {
858+ t .Fatalf ("expected restore marker stat error, got %v" , err )
859+ }
860+ }
861+
820862func TestSaveErrorsWhenWorkingDirectoryHasNoDotGradle (t * testing.T ) {
821863 ctx := context .Background ()
822864 gradleHome := t .TempDir ()
0 commit comments