mirror of
https://github.com/portainer/portainer.git
synced 2025-07-19 05:19:39 +02:00
feature(kubeconfig): access to all kube environment contexts from within the Portainer UI [EE-1727] (#5966)
This commit is contained in:
parent
c0a4727114
commit
6be1ff4d9c
22 changed files with 404 additions and 434 deletions
|
@ -45,3 +45,60 @@ func Test_IsKubernetesEndpoint(t *testing.T) {
|
|||
assert.Equal(t, test.expected, ans)
|
||||
}
|
||||
}
|
||||
|
||||
func Test_FilterByExcludeIDs(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
inputArray []portainer.Endpoint
|
||||
inputExcludeIDs []portainer.EndpointID
|
||||
asserts func(*testing.T, []portainer.Endpoint)
|
||||
}{
|
||||
{
|
||||
name: "filter endpoints",
|
||||
inputArray: []portainer.Endpoint{
|
||||
{ID: portainer.EndpointID(1)},
|
||||
{ID: portainer.EndpointID(2)},
|
||||
{ID: portainer.EndpointID(3)},
|
||||
{ID: portainer.EndpointID(4)},
|
||||
},
|
||||
inputExcludeIDs: []portainer.EndpointID{
|
||||
portainer.EndpointID(2),
|
||||
portainer.EndpointID(3),
|
||||
},
|
||||
asserts: func(t *testing.T, output []portainer.Endpoint) {
|
||||
assert.Contains(t, output, portainer.Endpoint{ID: portainer.EndpointID(1)})
|
||||
assert.NotContains(t, output, portainer.Endpoint{ID: portainer.EndpointID(2)})
|
||||
assert.NotContains(t, output, portainer.Endpoint{ID: portainer.EndpointID(3)})
|
||||
assert.Contains(t, output, portainer.Endpoint{ID: portainer.EndpointID(4)})
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "empty input",
|
||||
inputArray: []portainer.Endpoint{},
|
||||
inputExcludeIDs: []portainer.EndpointID{
|
||||
portainer.EndpointID(2),
|
||||
},
|
||||
asserts: func(t *testing.T, output []portainer.Endpoint) {
|
||||
assert.Equal(t, 0, len(output))
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "no filter",
|
||||
inputArray: []portainer.Endpoint{
|
||||
{ID: portainer.EndpointID(1)},
|
||||
{ID: portainer.EndpointID(2)},
|
||||
},
|
||||
inputExcludeIDs: []portainer.EndpointID{},
|
||||
asserts: func(t *testing.T, output []portainer.Endpoint) {
|
||||
assert.Equal(t, 2, len(output))
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
output := FilterByExcludeIDs(tt.inputArray, tt.inputExcludeIDs)
|
||||
tt.asserts(t, output)
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue