feat: it works
This commit is contained in:
parent
6302dd62d6
commit
778d5ef146
25 changed files with 638 additions and 106 deletions
66
internal/service/satellites_test.go
Normal file
66
internal/service/satellites_test.go
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
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))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue