mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-27 11:07:46 +01:00
feat(replication) sort the adapters shown on UI
Signed-off-by: Ziming Zhang <zziming@vmware.com>
This commit is contained in:
parent
7d53a61a92
commit
d1d0601841
@ -113,7 +113,7 @@ func HasFactory(t model.RegistryType) bool {
|
||||
// ListRegisteredAdapterTypes lists the registered Adapter type
|
||||
func ListRegisteredAdapterTypes() []model.RegistryType {
|
||||
types := []model.RegistryType{}
|
||||
for t := range registryKeys {
|
||||
for _, t := range registryKeys {
|
||||
types = append(types, model.RegistryType(t))
|
||||
}
|
||||
return types
|
||||
|
@ -57,6 +57,7 @@ func TestGetFactory(t *testing.T) {
|
||||
|
||||
func TestListRegisteredAdapterTypes(t *testing.T) {
|
||||
registry = map[model.RegistryType]Factory{}
|
||||
registryKeys = []string{}
|
||||
// not register, got nothing
|
||||
types := ListRegisteredAdapterTypes()
|
||||
assert.Equal(t, 0, len(types))
|
||||
@ -68,3 +69,17 @@ func TestListRegisteredAdapterTypes(t *testing.T) {
|
||||
require.Equal(t, 1, len(types))
|
||||
assert.Equal(t, model.RegistryType("harbor"), types[0])
|
||||
}
|
||||
|
||||
func TestListRegisteredAdapterTypesOrder(t *testing.T) {
|
||||
registry = map[model.RegistryType]Factory{}
|
||||
registryKeys = []string{}
|
||||
require.Nil(t, RegisterFactory("a", new(fakedFactory)))
|
||||
require.Nil(t, RegisterFactory("c", new(fakedFactory)))
|
||||
require.Nil(t, RegisterFactory("b", new(fakedFactory)))
|
||||
|
||||
types := ListRegisteredAdapterTypes()
|
||||
require.Equal(t, 3, len(types))
|
||||
require.Equal(t, model.RegistryType("a"), types[0])
|
||||
require.Equal(t, model.RegistryType("b"), types[1])
|
||||
require.Equal(t, model.RegistryType("c"), types[2])
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user