Skip to content

Commit 3442337

Browse files
committed
fix(tests): Round 22 - Fix 6 compilation errors
1. MockK8sClient.Apply method signature: - Changed from (ctx, Object, ...PatchOption) to (ctx, ApplyConfiguration, ...ApplyOption) - Matches controller-runtime v0.18+ API requirements 2. O2DMSClient httpClient field type: - Fixed all 6 test instances to wrap MockHTTPClient in &http.Client{} - Resolves type mismatch between mock and actual http.Client pointer 3. NephioPackager struct initialization: - Removed non-existent PorchClient, Repository, Namespace fields - Used actual struct fields: logger, workingDir, registry - Added missing log/slog import 4. Unused imports cleanup: - Removed unused labels import from monitoring_e2e_test.go - Removed unused require import from tn/agent/pkg/iperf_test.go 5. Added StackValidation type: - Defined missing type used by ValidateStack() method - Includes ComponentsRunning, HealthStatus, ValidationErrors, Timestamp Errors fixed: 6 total Total errors fixed across all 22 rounds: 119
1 parent ecb50fd commit 3442337

7 files changed

Lines changed: 22 additions & 13 deletions

File tree

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func TestO2DMSClient_GetInventory(t *testing.T) {
120120
client := &O2DMSClient{
121121
Endpoint: "http://test-o2dms:8080",
122122
Token: "test-token",
123-
httpClient: mockHTTP,
123+
httpClient: &http.Client{Transport: mockHTTP},
124124
maxRetries: 3,
125125
retryDelay: time.Second,
126126
}
@@ -213,7 +213,7 @@ func TestO2DMSClient_GetResources(t *testing.T) {
213213
client := &O2DMSClient{
214214
Endpoint: "http://test-o2dms:8080",
215215
Token: "test-token",
216-
httpClient: mockHTTP,
216+
httpClient: &http.Client{Transport: mockHTTP},
217217
}
218218

219219
result, err := client.GetResources(context.Background(), tt.filter)
@@ -275,7 +275,7 @@ func TestO2DMSClient_GetConfiguration(t *testing.T) {
275275
client := &O2DMSClient{
276276
Endpoint: "http://test-o2dms:8080",
277277
Token: "test-token",
278-
httpClient: mockHTTP,
278+
httpClient: &http.Client{Transport: mockHTTP},
279279
}
280280

281281
result, err := client.GetConfiguration(context.Background(), tt.resourceID)
@@ -350,7 +350,7 @@ func TestO2DMSClient_UpdateConfiguration(t *testing.T) {
350350
client := &O2DMSClient{
351351
Endpoint: "http://test-o2dms:8080",
352352
Token: "test-token",
353-
httpClient: mockHTTP,
353+
httpClient: &http.Client{Transport: mockHTTP},
354354
}
355355

356356
err := client.UpdateConfiguration(context.Background(), tt.resourceID, tt.config)
@@ -427,7 +427,7 @@ func TestO2DMSClient_RetryLogic(t *testing.T) {
427427
client := &O2DMSClient{
428428
Endpoint: "http://test-o2dms:8080",
429429
Token: "test-token",
430-
httpClient: mockHTTP,
430+
httpClient: &http.Client{Transport: mockHTTP},
431431
RetryCount: tt.retryCount,
432432
}
433433

@@ -490,7 +490,7 @@ func TestO2DMSClient_ErrorHandling(t *testing.T) {
490490
client := &O2DMSClient{
491491
Endpoint: "http://test-o2dms:8080",
492492
Token: "test-token",
493-
httpClient: mockHTTP,
493+
httpClient: &http.Client{Transport: mockHTTP},
494494
}
495495

496496
_, err := client.GetInventory(context.Background())
@@ -551,7 +551,7 @@ func TestO2DMSClient_Subscribe(t *testing.T) {
551551
client := &O2DMSClient{
552552
Endpoint: "http://test-o2dms:8080",
553553
Token: "test-token",
554-
httpClient: mockHTTP,
554+
httpClient: &http.Client{Transport: mockHTTP},
555555
}
556556

557557
result, err := client.Subscribe(context.Background(), tt.request)

adapters/vnf-operator/pkg/translator/nephio_packager_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package translator
22

33
import (
44
"context"
5+
"log/slog"
56
"testing"
67

78
"github.com/stretchr/testify/assert"
@@ -130,9 +131,9 @@ func TestNephioPackager_CreateVNFPackage(t *testing.T) {
130131

131132
// Create packager
132133
packager := &NephioPackager{
133-
PorchClient: mockPorch,
134-
Repository: "test-repo",
135-
Namespace: "oran-system",
134+
logger: slog.Default(),
135+
workingDir: "/tmp/nephio-packages",
136+
registry: "test-registry",
136137
}
137138

138139
// Execute test

adapters/vnf-operator/tests/e2e/monitoring_e2e_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"github.com/stretchr/testify/suite"
1818
corev1 "k8s.io/api/core/v1"
1919
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
20-
"k8s.io/apimachinery/pkg/labels"
2120
"k8s.io/apimachinery/pkg/util/wait"
2221
"k8s.io/client-go/kubernetes"
2322
"k8s.io/client-go/rest"

adapters/vnf-operator/tests/monitoring/e2e_observability_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,14 @@ type Notification struct {
191191
SentAt time.Time
192192
}
193193

194+
// StackValidation represents validation results
195+
type StackValidation struct {
196+
ComponentsRunning []string
197+
HealthStatus map[string]string
198+
ValidationErrors []string
199+
Timestamp time.Time
200+
}
201+
194202
// NotificationResult represents notification delivery result
195203
type NotificationResult struct {
196204
Receiver string

go.work.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ github.com/jessevdk/go-flags v1.6.1 h1:Cvu5U8UGrLay1rZfv/zP7iLpSHGUZ/Ou68T0iX1bB
162162
github.com/jessevdk/go-flags v1.6.1/go.mod h1:Mk8T1hIAWpOiJiHa9rJASDK2UGWji0EuPGBnNLMooyc=
163163
github.com/jonboulle/clockwork v0.5.0 h1:Hyh9A8u51kptdkR+cqRpT1EebBwTn1oK9YfGYbdFz6I=
164164
github.com/jonboulle/clockwork v0.5.0/go.mod h1:3mZlmanh0g2NDKO5TWZVJAfofYk64M7XN3SzBPjZF60=
165+
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
165166
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
166167
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
167168
github.com/kisielk/errcheck v1.5.0 h1:e8esj/e4R+SAOwFwN+n3zr0nYeCyeweozKfO23MvHzY=
@@ -170,6 +171,7 @@ github.com/klauspost/cpuid/v2 v2.2.9/go.mod h1:rqkxqrZ1EhYM9G+hXH7YdowN5R5RGN6NK
170171
github.com/knz/go-libedit v1.10.1 h1:0pHpWtx9vcvC0xGZqEQlQdfSQs7WRlAjuPvk3fOZDCo=
171172
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
172173
github.com/kr/pty v1.1.1 h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw=
174+
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
173175
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
174176
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
175177
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=

tests/mocks/k8s_client_mock.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func (m *MockK8sClient) Patch(ctx context.Context, obj client.Object, patch clie
8989
return nil
9090
}
9191

92-
func (m *MockK8sClient) Apply(ctx context.Context, obj client.Object, opts ...client.PatchOption) error {
92+
func (m *MockK8sClient) Apply(ctx context.Context, obj runtime.ApplyConfiguration, opts ...client.ApplyOption) error {
9393
return nil
9494
}
9595

tn/agent/pkg/iperf_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"time"
1111

1212
"github.com/stretchr/testify/assert"
13-
"github.com/stretchr/testify/require"
1413
"github.com/stretchr/testify/suite"
1514
)
1615

0 commit comments

Comments
 (0)