gsn-proxy/internal/service/satellites_test.go
2025-03-26 17:14:00 +03:00

66 lines
1.3 KiB
Go

package service
import (
"context"
"reflect"
"testing"
"git.intra.yksa.space/gsn/gsn-proxy/internal/pkg/ds"
"github.com/golang/mock/gomock"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
)
func Test_GetSatellites(t *testing.T) {
suite := NewSuite(t)
var (
commonSatelliteID = uuid.New()
commonDisplayName = "test"
commonStatus = ds.StatusActive
)
testCases := []struct {
name string
mock func()
expected []ds.Satellite
wantErr error
}{
{
name: "success",
mock: func() {
suite.mockRepo.EXPECT().GetSatellites(gomock.Any()).Return([]ds.Satellite{
{
ID: commonSatelliteID,
DisplayName: commonDisplayName,
Status: commonStatus,
},
}, nil)
},
expected: []ds.Satellite{
{
ID: commonSatelliteID,
DisplayName: commonDisplayName,
Status: commonStatus,
},
},
wantErr: nil,
},
}
for _, tt := range testCases {
t.Run(tt.name, func(t *testing.T) {
if tt.mock != nil {
tt.mock()
}
result, err := suite.svc.GetSatellites(context.Background())
if tt.wantErr != nil {
require.ErrorIs(t, err, tt.wantErr)
} else {
require.NoError(t, err)
require.True(t, reflect.DeepEqual(tt.expected, result))
}
})
}
}