Skip to content

Commit 3fb231b

Browse files
committed
fix(tests): Round 17 - Fix workflow template and compilation errors
- Fixed workflow timeout-minutes template (removed fromJson) - Fixed fixtures.mMTCVNFDeployment → MMTCVNFDeployment capitalization - Fixed O2DMSClient struct field names (BaseURL→Endpoint, AuthToken→Token, HTTPClient→httpClient, Timeout/RetryCount→maxRetries/retryDelay) - Removed unused metav1 import from deployment_controller_test.go - Added missing methods to MockK8sClient (SubResource, GroupVersionKindFor, IsObjectNamespaced) - Added MockSubResourceClient implementation Errors fixed: 8 total - 1 workflow template error - 2 fixture capitalization errors - 5 O2DMSClient field errors
1 parent 4c67aa4 commit 3fb231b

4 files changed

Lines changed: 39 additions & 8 deletions

File tree

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ jobs:
222222
223223
- name: Run unit tests with coverage
224224
working-directory: ${{ matrix.component.path }}
225-
timeout-minutes: ${{ fromJson(matrix.component.timeout) }}
225+
timeout-minutes: ${{ matrix.component.timeout }}
226226
run: |
227227
echo "Running unit tests for ${{ matrix.component.name }}"
228228

adapters/vnf-operator/pkg/controller/deployment_controller_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77

88
"github.com/stretchr/testify/assert"
99
"github.com/stretchr/testify/mock"
10-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1110
"k8s.io/apimachinery/pkg/runtime"
1211
"k8s.io/apimachinery/pkg/types"
1312
ctrl "sigs.k8s.io/controller-runtime"
@@ -140,7 +139,7 @@ func TestVNFDeploymentReconciler_Reconcile(t *testing.T) {
140139
},
141140
{
142141
name: "mmtc_slice_deployment",
143-
vnfDeployment: fixtures.mMTCVNFDeployment(),
142+
vnfDeployment: fixtures.MMTCVNFDeployment(),
144143
expectedResult: reconcile.Result{RequeueAfter: time.Minute * 5},
145144
expectedError: false,
146145
validateCalls: func(t *testing.T, mockK8s *mocks.MockK8sClient, mockDMS *MockDMSClient, mockGitOps *MockGitOpsClient) {

adapters/vnf-operator/pkg/dms/o2_client_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,11 @@ func TestO2DMSClient_GetInventory(t *testing.T) {
118118

119119
// Create client with mock
120120
client := &O2DMSClient{
121-
BaseURL: "http://test-o2dms:8080",
122-
AuthToken: "test-token",
123-
HTTPClient: mockHTTP,
124-
Timeout: time.Second * 30,
125-
RetryCount: 3,
121+
Endpoint: "http://test-o2dms:8080",
122+
Token: "test-token",
123+
httpClient: mockHTTP,
124+
maxRetries: 3,
125+
retryDelay: time.Second,
126126
}
127127

128128
// Execute test

tests/mocks/k8s_client_mock.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,38 @@ func (m *MockK8sClient) RESTMapper() meta.RESTMapper {
105105
return nil
106106
}
107107

108+
func (m *MockK8sClient) SubResource(subResource string) client.SubResourceClient {
109+
return &MockSubResourceClient{}
110+
}
111+
112+
// GroupVersionKindFor returns GVK for the given object
113+
func (m *MockK8sClient) GroupVersionKindFor(obj runtime.Object) (schema.GroupVersionKind, error) {
114+
return schema.GroupVersionKind{}, nil
115+
}
116+
117+
// IsObjectNamespaced returns true if the object is namespaced
118+
func (m *MockK8sClient) IsObjectNamespaced(obj runtime.Object) (bool, error) {
119+
return true, nil
120+
}
121+
122+
type MockSubResourceClient struct{}
123+
124+
func (m *MockSubResourceClient) Get(ctx context.Context, obj client.Object, subResource client.Object, opts ...client.SubResourceGetOption) error {
125+
return nil
126+
}
127+
128+
func (m *MockSubResourceClient) Create(ctx context.Context, obj client.Object, subResource client.Object, opts ...client.SubResourceCreateOption) error {
129+
return nil
130+
}
131+
132+
func (m *MockSubResourceClient) Update(ctx context.Context, obj client.Object, opts ...client.SubResourceUpdateOption) error {
133+
return nil
134+
}
135+
136+
func (m *MockSubResourceClient) Patch(ctx context.Context, obj client.Object, patch client.Patch, opts ...client.SubResourcePatchOption) error {
137+
return nil
138+
}
139+
108140
type MockStatusWriter struct{}
109141

110142
func (m *MockStatusWriter) Create(ctx context.Context, obj client.Object, subResource client.Object, opts ...client.SubResourceCreateOption) error {

0 commit comments

Comments
 (0)