moving comment about sorting for clarity

Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
This commit is contained in:
David Lawrence 2015-12-16 16:42:27 -08:00
parent a3002aafd8
commit a27e4f7471
2 changed files with 3 additions and 3 deletions

View File

@ -139,10 +139,10 @@ func loadAndValidateTargets(gun string, repo *tuf.Repo, roles map[string]storage
}
}
// by sorting, we'll always process shallower targets updates before deeper
// N.B. RoleList sorts paths with fewer segments first.
// By sorting, we'll always process shallower targets updates before deeper
// ones (i.e. we'll load and validate targets before targets/foo). This
// helps ensure we only load from storage when necessary in a cleaner way.
// RoleList sorts paths with fewer segments first
sort.Sort(targetsRoles)
updatesToApply := make([]storage.MetaUpdate, 0, len(targetsRoles))

View File

@ -16,7 +16,7 @@ func TestRoleListLess(t *testing.T) {
rl := RoleList{"foo", "foo/bar", "bar/foo"}
assert.True(t, rl.Less(0, 1))
assert.False(t, rl.Less(1, 2))
assert.False(t, rl.Less(2, 1))
assert.True(t, rl.Less(2, 1))
}
func TestRoleListSwap(t *testing.T) {