Skip to content

Commit 547a2db

Browse files
committed
registry: TestNewIndexInfo: inline testIndexInfo (thelper)
It's not really a helper, and it's trivial to inline it; registry/registry_test.go:366:19: test helper function should start from t.Helper() (thelper) testIndexInfo := func(t *testing.T, config *serviceConfig, expectedIndexInfos map[string]*registry.IndexInfo) { ^ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 5ea7857 commit 547a2db

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

registry/registry_test.go

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -363,15 +363,6 @@ func TestNewIndexInfo(t *testing.T) {
363363
},
364364
}
365365

366-
testIndexInfo := func(t *testing.T, config *serviceConfig, expectedIndexInfos map[string]*registry.IndexInfo) {
367-
for indexName, expected := range expectedIndexInfos {
368-
t.Run(indexName, func(t *testing.T) {
369-
actual := newIndexInfo(config, indexName)
370-
assert.Check(t, is.DeepEqual(actual, expected))
371-
})
372-
}
373-
}
374-
375366
expectedIndexInfos := map[string]*registry.IndexInfo{
376367
IndexName: {
377368
Name: IndexName,
@@ -399,7 +390,12 @@ func TestNewIndexInfo(t *testing.T) {
399390
},
400391
}
401392
t.Run("no mirrors", func(t *testing.T) {
402-
testIndexInfo(t, emptyServiceConfig, expectedIndexInfos)
393+
for indexName, expected := range expectedIndexInfos {
394+
t.Run(indexName, func(t *testing.T) {
395+
actual := newIndexInfo(emptyServiceConfig, indexName)
396+
assert.Check(t, is.DeepEqual(actual, expected))
397+
})
398+
}
403399
})
404400

405401
expectedIndexInfos = map[string]*registry.IndexInfo{
@@ -494,7 +490,12 @@ func TestNewIndexInfo(t *testing.T) {
494490
InsecureRegistries: []string{"example.com"},
495491
})
496492
assert.NilError(t, err)
497-
testIndexInfo(t, config, expectedIndexInfos)
493+
for indexName, expected := range expectedIndexInfos {
494+
t.Run(indexName, func(t *testing.T) {
495+
actual := newIndexInfo(config, indexName)
496+
assert.Check(t, is.DeepEqual(actual, expected))
497+
})
498+
}
498499
})
499500

500501
expectedIndexInfos = map[string]*registry.IndexInfo{
@@ -546,7 +547,12 @@ func TestNewIndexInfo(t *testing.T) {
546547
InsecureRegistries: []string{"42.42.0.0/16"},
547548
})
548549
assert.NilError(t, err)
549-
testIndexInfo(t, config, expectedIndexInfos)
550+
for indexName, expected := range expectedIndexInfos {
551+
t.Run(indexName, func(t *testing.T) {
552+
actual := newIndexInfo(config, indexName)
553+
assert.Check(t, is.DeepEqual(actual, expected))
554+
})
555+
}
550556
})
551557
}
552558

0 commit comments

Comments
 (0)