private CacheServerResolver CreateResolver(MockGVFSEnlistment enlistment = null) { enlistment = enlistment ?? this.CreateEnlistment(); return(new CacheServerResolver(new MockTracer(), enlistment)); }
private void TestSetup(DateTime lastRun) { string lastRunTime = EpochConverter.ToUnixEpochSeconds(lastRun).ToString(); // Create GitProcess this.gitProcess = new MockGitProcess(); this.gitProcess.SetExpectedCommandResult( PrunePackedCommand, () => new GitProcess.Result(string.Empty, string.Empty, GitProcess.Result.SuccessCode)); // Create enlistment using git process GVFSEnlistment enlistment = new MockGVFSEnlistment(this.gitProcess); string packPrefix = Path.Combine(enlistment.GitPackRoot, "from-loose"); this.packCommand = $"pack-objects {packPrefix} --non-empty --window=0 --depth=0 -q"; this.gitProcess.SetExpectedCommandResult( this.packCommand, () => new GitProcess.Result(string.Empty, string.Empty, GitProcess.Result.SuccessCode)); // Create a last run time file MockFile timeFile = new MockFile(Path.Combine(enlistment.GitObjectsRoot, "info", LooseObjectsStep.LooseObjectsLastRunFileName), lastRunTime); // Create info directory to hold last run time file MockDirectory infoRoot = new MockDirectory(Path.Combine(enlistment.GitObjectsRoot, "info"), null, new List <MockFile>() { timeFile }); // Create Hex Folder 1 with 1 File MockDirectory hex1 = new MockDirectory( Path.Combine(enlistment.GitObjectsRoot, "AA"), null, new List <MockFile>() { new MockFile(Path.Combine(enlistment.GitObjectsRoot, "AA", "1156f4f2b850673090c285289ea8475d629fe1"), string.Empty) }); // Create Hex Folder 2 with 2 Files MockDirectory hex2 = new MockDirectory( Path.Combine(enlistment.GitObjectsRoot, "F1"), null, new List <MockFile>() { new MockFile(Path.Combine(enlistment.GitObjectsRoot, "F1", "1156f4f2b850673090c285289ea8475d629fe2"), string.Empty), new MockFile(Path.Combine(enlistment.GitObjectsRoot, "F1", "1156f4f2b850673090c285289ea8475d629fe3"), string.Empty) }); // Create NonHex Folder with 4 Files MockDirectory nonhex = new MockDirectory( Path.Combine(enlistment.GitObjectsRoot, "ZZ"), null, new List <MockFile>() { new MockFile(Path.Combine(enlistment.GitObjectsRoot, "ZZ", "1156f4f2b850673090c285289ea8475d629fe4"), string.Empty), new MockFile(Path.Combine(enlistment.GitObjectsRoot, "ZZ", "1156f4f2b850673090c285289ea8475d629fe5"), string.Empty), new MockFile(Path.Combine(enlistment.GitObjectsRoot, "ZZ", "1156f4f2b850673090c285289ea8475d629fe6"), string.Empty), new MockFile(Path.Combine(enlistment.GitObjectsRoot, "ZZ", "1156f4f2b850673090c285289ea8475d629fe7"), string.Empty) }); // Create git objects directory MockDirectory gitObjectsRoot = new MockDirectory(enlistment.GitObjectsRoot, new List <MockDirectory>() { infoRoot, hex1, hex2, nonhex }, null); // Add object directory to file System List <MockDirectory> directories = new List <MockDirectory>() { gitObjectsRoot }; PhysicalFileSystem fileSystem = new MockFileSystem(new MockDirectory(enlistment.EnlistmentRoot, directories, null)); // Create and return Context this.tracer = new MockTracer(); this.context = new GVFSContext(this.tracer, fileSystem, repository: null, enlistment: enlistment); }
private void TestSetup(DateTime lastRun, bool failOnVerify = false) { string lastRunTime = EpochConverter.ToUnixEpochSeconds(lastRun).ToString(); this.gitProcess = new MockGitProcess(); // Create enlistment using git process GVFSEnlistment enlistment = new MockGVFSEnlistment(this.gitProcess); // Create a last run time file MockFile timeFile = new MockFile(Path.Combine(enlistment.GitObjectsRoot, "info", PackfileMaintenanceStep.PackfileLastRunFileName), lastRunTime); // Create info directory to hold last run time file MockDirectory info = new MockDirectory( Path.Combine(enlistment.GitObjectsRoot, "info"), null, new List <MockFile>() { timeFile }); // Create pack info MockDirectory pack = new MockDirectory( enlistment.GitPackRoot, null, new List <MockFile>() { new MockFile(Path.Combine(enlistment.GitPackRoot, "pack-1.pack"), "one"), new MockFile(Path.Combine(enlistment.GitPackRoot, "pack-1.idx"), "1"), new MockFile(Path.Combine(enlistment.GitPackRoot, "pack-2.pack"), "two"), new MockFile(Path.Combine(enlistment.GitPackRoot, "pack-2.idx"), "2"), new MockFile(Path.Combine(enlistment.GitPackRoot, "pack-3.pack"), "three"), new MockFile(Path.Combine(enlistment.GitPackRoot, "pack-3.idx"), "3"), new MockFile(Path.Combine(enlistment.GitPackRoot, KeepName), string.Empty), new MockFile(Path.Combine(enlistment.GitPackRoot, StaleIdxName), "4"), }); // Create git objects directory MockDirectory gitObjectsRoot = new MockDirectory(enlistment.GitObjectsRoot, new List <MockDirectory>() { info, pack }, null); // Add object directory to file System List <MockDirectory> directories = new List <MockDirectory>() { gitObjectsRoot }; PhysicalFileSystem fileSystem = new MockFileSystem(new MockDirectory(enlistment.EnlistmentRoot, directories, null)); MockGitRepo repository = new MockGitRepo(this.tracer, enlistment, fileSystem); // Create and return Context this.tracer = new MockTracer(); this.context = new GVFSContext(this.tracer, fileSystem, repository, enlistment); this.gitProcess.SetExpectedCommandResult( this.WriteCommand, () => new GitProcess.Result(string.Empty, string.Empty, GitProcess.Result.SuccessCode)); this.gitProcess.SetExpectedCommandResult( this.ExpireCommand, () => new GitProcess.Result(string.Empty, string.Empty, GitProcess.Result.SuccessCode)); this.gitProcess.SetExpectedCommandResult( this.VerifyCommand, () => new GitProcess.Result(string.Empty, string.Empty, failOnVerify ? GitProcess.Result.GenericFailureCode : GitProcess.Result.SuccessCode)); this.gitProcess.SetExpectedCommandResult( this.RepackCommand, () => new GitProcess.Result(string.Empty, string.Empty, GitProcess.Result.SuccessCode)); }
private MockHttpGitObjects(MockGVFSEnlistment enlistment) : base(new MockTracer(), enlistment, new MockCacheServerInfo(), new RetryConfig(maxRetries: 1)) { }