mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 15:59:41 +02:00
refactor(edge/updates): sync changes from EE [EE-4288] (#7726)
This commit is contained in:
parent
4fee359247
commit
82e9e2a895
80 changed files with 1099 additions and 1892 deletions
41
api/internal/edge/edgestacks/service_test.go
Normal file
41
api/internal/edge/edgestacks/service_test.go
Normal file
|
@ -0,0 +1,41 @@
|
|||
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))
|
||||
|
||||
service := NewService(dataStore)
|
||||
|
||||
err := service.updateEndpointRelations(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])
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue