1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 07:49:41 +02:00

feat(edgestacks): support kubernetes edge stacks (#5276) [EE-393]

This commit is contained in:
Chaim Lev-Ari 2021-09-09 11:38:34 +03:00 committed by GitHub
parent 79ca51c92e
commit 5c8450c4c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
56 changed files with 1466 additions and 521 deletions

View file

@ -0,0 +1,38 @@
package edgestacks
import (
"testing"
portainer "github.com/portainer/portainer/api"
"github.com/portainer/portainer/api/internal/testhelpers"
"github.com/stretchr/testify/assert"
)
func Test_updateEndpointRelation_successfulRuns(t *testing.T) {
edgeStackID := portainer.EdgeStackID(5)
endpointRelations := []portainer.EndpointRelation{
{EndpointID: 1, EdgeStacks: map[portainer.EdgeStackID]bool{}},
{EndpointID: 2, EdgeStacks: map[portainer.EdgeStackID]bool{}},
{EndpointID: 3, EdgeStacks: map[portainer.EdgeStackID]bool{}},
{EndpointID: 4, EdgeStacks: map[portainer.EdgeStackID]bool{}},
{EndpointID: 5, EdgeStacks: map[portainer.EdgeStackID]bool{}},
}
relatedIds := []portainer.EndpointID{2, 3}
dataStore := testhelpers.NewDatastore(testhelpers.WithEndpointRelations(endpointRelations))
err := updateEndpointRelations(dataStore.EndpointRelation(), edgeStackID, relatedIds)
assert.NoError(t, err, "updateEndpointRelations should not fail")
relatedSet := map[portainer.EndpointID]bool{}
for _, relationID := range relatedIds {
relatedSet[relationID] = true
}
for _, relation := range endpointRelations {
shouldBeRelated := relatedSet[relation.EndpointID]
assert.Equal(t, shouldBeRelated, relation.EdgeStacks[edgeStackID])
}
}