yaml format changes

This commit is contained in:
tanyamadaan
2025-03-28 17:01:47 +05:30
parent dff7a5abb3
commit a549323dd5
5 changed files with 49 additions and 71 deletions

View File

@@ -32,44 +32,21 @@ func setupTestConfig(t *testing.T) string {
return tempPath
}
// TestRouterProviderSuccess tests the RouterProvider implementation for success cases.
// TestRouterProviderSuccess tests successful router creation.
func TestRouterProviderSuccess(t *testing.T) {
rulesFilePath := setupTestConfig(t)
defer os.RemoveAll(filepath.Dir(rulesFilePath))
// Define test cases
tests := []struct {
name string
ctx context.Context
config map[string]string
wantErr bool
}{
{
name: "Valid configuration",
ctx: context.Background(),
config: map[string]string{
"routingConfig": rulesFilePath,
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
provider := RouterProvider{}
router, _, err := provider.New(tt.ctx, tt.config)
// Ensure no error occurred
if (err != nil) != tt.wantErr {
t.Errorf("New(%v, %v) error = %v, wantErr %v", tt.ctx, tt.config, err, tt.wantErr)
return
}
// Ensure the router and close function are not nil
if router == nil {
t.Errorf("New(%v, %v) = nil router, want non-nil", tt.ctx, tt.config)
}
router, _, err := provider.New(context.Background(), map[string]string{
"routingConfig": rulesFilePath,
})
if err != nil {
t.Fatalf("New() unexpected error: %v", err)
}
if router == nil {
t.Error("New() returned nil router, want non-nil")
}
}
@@ -114,8 +91,9 @@ func TestRouterProviderFailure(t *testing.T) {
// Check for expected error
if err == nil {
t.Errorf("New(%v, %v) = nil error, want error containing %q", tt.ctx, tt.config, tt.wantErr)
} else if !strings.Contains(err.Error(), tt.wantErr) {
t.Fatalf("New(%v, %v) = nil error, want error containing %q", tt.ctx, tt.config, tt.wantErr)
}
if !strings.Contains(err.Error(), tt.wantErr) {
t.Errorf("New(%v, %v) = %v, want error containing %q", tt.ctx, tt.config, err, tt.wantErr)
}
})

View File

@@ -1,23 +1,23 @@
routingRules:
- domain: "ONDC:TRV10"
version: "2.0.0"
targetType: "bpp"
- domain: ONDC:TRV10
version: 2.0.0
targetType: bpp
target:
url: "https://gateway.example.com"
url: https://gateway.example.com
endpoints:
- search
- domain: "ONDC:TRV10"
version: "2.0.0"
targetType: "bpp"
- domain: ONDC:TRV10
version: 2.0.0
targetType: bpp
endpoints:
- select
- init
- confirm
- status
- cancel
- domain: "ONDC:TRV12"
version: "2.0.0"
targetType: "bpp"
- domain: ONDC:TRV12
version: 2.0.0
targetType: bpp
endpoints:
- select
- init

View File

@@ -1,9 +1,9 @@
routingRules:
- domain: "ONDC:TRV10"
version: "2.0.0"
targetType: "url"
- domain: ONDC:TRV10
version: 2.0.0
targetType: url
target:
url: "https://services-backend/trv/v1"
url: https://services-backend/trv/v1
endpoints:
- on_select
- on_init
@@ -11,10 +11,10 @@ routingRules:
- on_status
- on_update
- on_cancel
- domain: "ONDC:TRV10"
version: "2.0.0"
targetType: "publisher"
- domain: ONDC:TRV10
version: 2.0.0
targetType: publisher
target:
publisherId: "trv_topic_id1"
publisherId: trv_topic_id1
endpoints:
- on_search

View File

@@ -1,7 +1,7 @@
routingRules:
- domain: "ONDC:TRV10"
version: "2.0.0"
targetType: "bap"
- domain: ONDC:TRV10
version: 2.0.0
targetType: bap
endpoints:
- on_search
- on_select
@@ -10,9 +10,9 @@ routingRules:
- on_status
- on_update
- on_cancel
- domain: "ONDC:TRV11"
version: "2.0.0"
targetType: "bap"
- domain: ONDC:TRV11
version: 2.0.0
targetType: bap
endpoints:
- on_search
- on_select

View File

@@ -1,27 +1,27 @@
routingRules:
- domain: "ONDC:TRV10"
version: "2.0.0"
targetType: "url"
- domain: ONDC:TRV10
version: 2.0.0
targetType: url
target:
url: "https://services-backend/trv/v1"
url: https://services-backend/trv/v1
endpoints:
- select
- init
- confirm
- status
- cancel
- domain: "ONDC:TRV10"
version: "2.0.0"
targetType: "publisher"
- domain: ONDC:TRV10
version: 2.0.0
targetType: publisher
target:
publisherId: "trv_topic_id1"
publisherId: trv_topic_id1
endpoints:
- search
- domain: "ONDC:TRV11"
version: "2.0.0"
targetType: "url"
- domain: ONDC:TRV11
version: 2.0.0
targetType: url
target:
url: "https://services-backend/trv/v1"
url: https://services-backend/trv/v1
endpoints:
- select
- init