Skip to content

Commit cd9e0c3

Browse files
committed
TestBomb(): don't instantiate an Assertions object
The other test functions don't, so doing it in this one function was confusing.
1 parent 7155294 commit cd9e0c3

File tree

1 file changed

+40
-43
lines changed

1 file changed

+40
-43
lines changed

git_sizer_test.go

Lines changed: 40 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ func pow(x uint64, n int) uint64 {
133133

134134
func TestBomb(t *testing.T) {
135135
t.Parallel()
136-
assert := assert.New(t)
137136

138137
path, err := ioutil.TempDir("", "bomb")
139138
require.NoError(t, err)
@@ -147,49 +146,47 @@ func TestBomb(t *testing.T) {
147146
h, err := sizes.ScanRepositoryUsingGraph(
148147
repo, git.AllReferencesFilter, sizes.NameStyleFull, false,
149148
)
150-
if !assert.NoError(err) {
151-
return
152-
}
149+
require.NoError(t, err)
153150

154-
assert.Equal(counts.Count32(1), h.UniqueCommitCount, "unique commit count")
155-
assert.Equal(counts.Count64(172), h.UniqueCommitSize, "unique commit size")
156-
assert.Equal(counts.Count32(172), h.MaxCommitSize, "max commit size")
157-
assert.Equal("refs/heads/master", h.MaxCommitSizeCommit.Path(), "max commit size commit")
158-
assert.Equal(counts.Count32(1), h.MaxHistoryDepth, "max history depth")
159-
assert.Equal(counts.Count32(0), h.MaxParentCount, "max parent count")
160-
assert.Equal("refs/heads/master", h.MaxParentCountCommit.Path(), "max parent count commit")
161-
162-
assert.Equal(counts.Count32(10), h.UniqueTreeCount, "unique tree count")
163-
assert.Equal(counts.Count64(2910), h.UniqueTreeSize, "unique tree size")
164-
assert.Equal(counts.Count64(100), h.UniqueTreeEntries, "unique tree entries")
165-
assert.Equal(counts.Count32(10), h.MaxTreeEntries, "max tree entries")
166-
assert.Equal("refs/heads/master:d0/d0/d0/d0/d0/d0/d0/d0/d0", h.MaxTreeEntriesTree.Path(), "max tree entries tree")
167-
168-
assert.Equal(counts.Count32(1), h.UniqueBlobCount, "unique blob count")
169-
assert.Equal(counts.Count64(6), h.UniqueBlobSize, "unique blob size")
170-
assert.Equal(counts.Count32(6), h.MaxBlobSize, "max blob size")
171-
assert.Equal("refs/heads/master:d0/d0/d0/d0/d0/d0/d0/d0/d0/f0", h.MaxBlobSizeBlob.Path(), "max blob size blob")
172-
173-
assert.Equal(counts.Count32(0), h.UniqueTagCount, "unique tag count")
174-
assert.Equal(counts.Count32(0), h.MaxTagDepth, "max tag depth")
175-
176-
assert.Equal(counts.Count32(1), h.ReferenceCount, "reference count")
177-
178-
assert.Equal(counts.Count32(10), h.MaxPathDepth, "max path depth")
179-
assert.Equal("refs/heads/master^{tree}", h.MaxPathDepthTree.Path(), "max path depth tree")
180-
assert.Equal(counts.Count32(29), h.MaxPathLength, "max path length")
181-
assert.Equal("refs/heads/master^{tree}", h.MaxPathLengthTree.Path(), "max path length tree")
182-
183-
assert.Equal(counts.Count32((pow(10, 10)-1)/(10-1)), h.MaxExpandedTreeCount, "max expanded tree count")
184-
assert.Equal("refs/heads/master^{tree}", h.MaxExpandedTreeCountTree.Path(), "max expanded tree count tree")
185-
assert.Equal(counts.Count32(0xffffffff), h.MaxExpandedBlobCount, "max expanded blob count")
186-
assert.Equal("refs/heads/master^{tree}", h.MaxExpandedBlobCountTree.Path(), "max expanded blob count tree")
187-
assert.Equal(counts.Count64(6*pow(10, 10)), h.MaxExpandedBlobSize, "max expanded blob size")
188-
assert.Equal("refs/heads/master^{tree}", h.MaxExpandedBlobSizeTree.Path(), "max expanded blob size tree")
189-
assert.Equal(counts.Count32(0), h.MaxExpandedLinkCount, "max expanded link count")
190-
assert.Nil(h.MaxExpandedLinkCountTree, "max expanded link count tree")
191-
assert.Equal(counts.Count32(0), h.MaxExpandedSubmoduleCount, "max expanded submodule count")
192-
assert.Nil(h.MaxExpandedSubmoduleCountTree, "max expanded submodule count tree")
151+
assert.Equal(t, counts.Count32(1), h.UniqueCommitCount, "unique commit count")
152+
assert.Equal(t, counts.Count64(172), h.UniqueCommitSize, "unique commit size")
153+
assert.Equal(t, counts.Count32(172), h.MaxCommitSize, "max commit size")
154+
assert.Equal(t, "refs/heads/master", h.MaxCommitSizeCommit.Path(), "max commit size commit")
155+
assert.Equal(t, counts.Count32(1), h.MaxHistoryDepth, "max history depth")
156+
assert.Equal(t, counts.Count32(0), h.MaxParentCount, "max parent count")
157+
assert.Equal(t, "refs/heads/master", h.MaxParentCountCommit.Path(), "max parent count commit")
158+
159+
assert.Equal(t, counts.Count32(10), h.UniqueTreeCount, "unique tree count")
160+
assert.Equal(t, counts.Count64(2910), h.UniqueTreeSize, "unique tree size")
161+
assert.Equal(t, counts.Count64(100), h.UniqueTreeEntries, "unique tree entries")
162+
assert.Equal(t, counts.Count32(10), h.MaxTreeEntries, "max tree entries")
163+
assert.Equal(t, "refs/heads/master:d0/d0/d0/d0/d0/d0/d0/d0/d0", h.MaxTreeEntriesTree.Path(), "max tree entries tree")
164+
165+
assert.Equal(t, counts.Count32(1), h.UniqueBlobCount, "unique blob count")
166+
assert.Equal(t, counts.Count64(6), h.UniqueBlobSize, "unique blob size")
167+
assert.Equal(t, counts.Count32(6), h.MaxBlobSize, "max blob size")
168+
assert.Equal(t, "refs/heads/master:d0/d0/d0/d0/d0/d0/d0/d0/d0/f0", h.MaxBlobSizeBlob.Path(), "max blob size blob")
169+
170+
assert.Equal(t, counts.Count32(0), h.UniqueTagCount, "unique tag count")
171+
assert.Equal(t, counts.Count32(0), h.MaxTagDepth, "max tag depth")
172+
173+
assert.Equal(t, counts.Count32(1), h.ReferenceCount, "reference count")
174+
175+
assert.Equal(t, counts.Count32(10), h.MaxPathDepth, "max path depth")
176+
assert.Equal(t, "refs/heads/master^{tree}", h.MaxPathDepthTree.Path(), "max path depth tree")
177+
assert.Equal(t, counts.Count32(29), h.MaxPathLength, "max path length")
178+
assert.Equal(t, "refs/heads/master^{tree}", h.MaxPathLengthTree.Path(), "max path length tree")
179+
180+
assert.Equal(t, counts.Count32((pow(10, 10)-1)/(10-1)), h.MaxExpandedTreeCount, "max expanded tree count")
181+
assert.Equal(t, "refs/heads/master^{tree}", h.MaxExpandedTreeCountTree.Path(), "max expanded tree count tree")
182+
assert.Equal(t, counts.Count32(0xffffffff), h.MaxExpandedBlobCount, "max expanded blob count")
183+
assert.Equal(t, "refs/heads/master^{tree}", h.MaxExpandedBlobCountTree.Path(), "max expanded blob count tree")
184+
assert.Equal(t, counts.Count64(6*pow(10, 10)), h.MaxExpandedBlobSize, "max expanded blob size")
185+
assert.Equal(t, "refs/heads/master^{tree}", h.MaxExpandedBlobSizeTree.Path(), "max expanded blob size tree")
186+
assert.Equal(t, counts.Count32(0), h.MaxExpandedLinkCount, "max expanded link count")
187+
assert.Nil(t, h.MaxExpandedLinkCountTree, "max expanded link count tree")
188+
assert.Equal(t, counts.Count32(0), h.MaxExpandedSubmoduleCount, "max expanded submodule count")
189+
assert.Nil(t, h.MaxExpandedSubmoduleCountTree, "max expanded submodule count tree")
193190
}
194191

195192
func TestTaggedTags(t *testing.T) {

0 commit comments

Comments
 (0)