Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented clear command for removing all cached chunks
- Loading branch information
Mark Dunham
committed
Jan 5, 2012
1 parent
98ba9df
commit 22df260
Showing
14 changed files
with
275 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using GitBin; | ||
using GitBin.Commands; | ||
using Moq; | ||
using NUnit.Framework; | ||
|
||
namespace git_bin.Tests.Commands | ||
{ | ||
[TestFixture] | ||
public class ClearCommandTest | ||
{ | ||
private Mock<ICacheManager> _cacheManager; | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
_cacheManager = new Mock<ICacheManager>(MockBehavior.Strict); | ||
} | ||
|
||
[Test] | ||
public void Execute_Force_CallsClearCache() | ||
{ | ||
_cacheManager.Setup(x => x.ClearCache()).Verifiable(); | ||
|
||
var target = new ClearCommand(_cacheManager.Object, new[] {"-f"}); | ||
target.Execute(); | ||
|
||
_cacheManager.Verify(); | ||
} | ||
|
||
[Test] | ||
public void Execute_DryRun_DoesNotClearCache() | ||
{ | ||
// mock is strict, so calling ClearCache will throw | ||
_cacheManager.Setup(x => x.ListFiles()).Returns(new GitBinFileInfo[0]); | ||
|
||
var target = new ClearCommand(_cacheManager.Object, new[] { "-n" }); | ||
target.Execute(); | ||
|
||
Assert.Pass(); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using GitBin; | ||
using GitBin.Commands; | ||
using GitBin.Remotes; | ||
using Moq; | ||
using NUnit.Framework; | ||
|
||
namespace git_bin.Tests | ||
{ | ||
[TestFixture] | ||
public class GitBinFileInfoUtilsTest | ||
{ | ||
[Test] | ||
public void GetHumanReadableSize_LessThanOrEqualTo1K_StringIsBytes() | ||
{ | ||
var zero = GitBinFileInfoUtils.GetHumanReadableSize(0); | ||
var fifty = GitBinFileInfoUtils.GetHumanReadableSize(50); | ||
var kilobyte = GitBinFileInfoUtils.GetHumanReadableSize(1024); | ||
|
||
Assert.AreEqual("0B", zero); | ||
Assert.AreEqual("50B", fifty); | ||
Assert.AreEqual("1k", kilobyte); | ||
} | ||
|
||
[Test] | ||
public void GetHumanReadableSize_Between1KAnd1MInclusive_StringIsKB() | ||
{ | ||
var ninePointEight = GitBinFileInfoUtils.GetHumanReadableSize(10035); | ||
var megabyte = GitBinFileInfoUtils.GetHumanReadableSize(1024 * 1024); | ||
|
||
Assert.AreEqual("9.8k", ninePointEight); | ||
Assert.AreEqual("1M", megabyte); | ||
} | ||
|
||
[Test] | ||
public void GetHumanReadableSize_Between1Mand1GInclusive_StringIsMB() | ||
{ | ||
var fourPointTwo = GitBinFileInfoUtils.GetHumanReadableSize(4404019); | ||
var gigabyte = GitBinFileInfoUtils.GetHumanReadableSize(1024 * 1024 * 1024); | ||
|
||
Assert.AreEqual("4.2M", fourPointTwo); | ||
Assert.AreEqual("1G", gigabyte); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.