Skip to content

Commit

Permalink
Adding unit tests for custom Webui URL (#243)
Browse files Browse the repository at this point in the history
Signed-off-by: gatici <[email protected]>
  • Loading branch information
gatici authored Apr 4, 2024
1 parent b61f238 commit 3007f95
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
1 change: 0 additions & 1 deletion config/smfcfg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ configuration:
- A: gNB
B: UPF1
nrfUri: http://nrf:29510 # a valid URI of NRF
webuiUri: webui:9876 # a valid URI of Webui

# the kind of log output
# debugLevel: how detailed to output, value: trace, debug, info, warn, error, fatal, panic
Expand Down
15 changes: 15 additions & 0 deletions config/smfcfg_with_custom_webui_url.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: 2024 Canonical Ltd.

info:
version: 1.0.0
description: SMF initial local configuration

configuration:
enableDBStore: false
enableUPFAdapter: true
debugProfilePort: 5001
smfName: SMF # the name of this SMF
nrfUri: http://nrf:29510 # a valid URI of NRF
webuiUri: myspecialwebui:9872 # a valid URI of Webui

22 changes: 22 additions & 0 deletions factory/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
package factory

import (
"fmt"
"github.com/stretchr/testify/assert"
"testing"

protos "github.com/omec-project/config5g/proto/sdcoreConfig"
Expand Down Expand Up @@ -426,3 +428,23 @@ func TestKafkaEnabledByDefault(t *testing.T) {
t.Errorf("Expected Kafka to be enabled by default, was disabled")
}
}

// Webui URL is not set then default Webui URL value is returned
func TestGetDefaultWebuiUrl(t *testing.T) {
if err := InitConfigFactory("../config/smfcfg.yaml"); err != nil {
fmt.Printf("Error in InitConfigFactory: %v\n", err)
}
got := SmfConfig.Configuration.WebuiUri
want := "webui:9876"
assert.Equal(t, got, want, "The webui URL is not correct.")
}

// Webui URL is set to a custom value then custom Webui URL is returned
func TestGetCustomWebuiUrl(t *testing.T) {
if err := InitConfigFactory("../config/smfcfg_with_custom_webui_url.yaml"); err != nil {
fmt.Printf("Error in InitConfigFactory: %v\n", err)
}
got := SmfConfig.Configuration.WebuiUri
want := "myspecialwebui:9872"
assert.Equal(t, got, want, "The webui URL is not correct.")
}

0 comments on commit 3007f95

Please sign in to comment.