Skip to content

Commit

Permalink
chore: Adding unit tests for custom Webui URL (#223)
Browse files Browse the repository at this point in the history
* Adding unit tests for custom Webui URL

Signed-off-by: gatici <[email protected]>

* Apply suggestions from code review

---------

Signed-off-by: gatici <[email protected]>
Co-authored-by: gab-arrobo <[email protected]>
  • Loading branch information
gatici and gab-arrobo committed Apr 2, 2024
1 parent 19aba2c commit 538564c
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
1 change: 0 additions & 1 deletion amfTest/amfcfg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ configuration:
supportDnnList: # the DNN (Data Network Name) list supported by this AMF
- internet
nrfUri: http://127.0.0.10:8000 # a valid URI of NRF
webuiUri: webui:9876 # a valid URI of Webui
security: # NAS security parameters
integrityOrder: # the priority of integrity algorithms
- NIA2
Expand Down
12 changes: 12 additions & 0 deletions amfTest/amfcfg_with_custom_webui_url.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: 2024 Canonical Ltd.

info:
version: 1.0.0
description: AMF initial local configuration

configuration:
amfName: AMF # the name of this AMF
webuiUri: myspecialwebui:9872 # a valid URI of Webui


34 changes: 34 additions & 0 deletions factory/amf_config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2024 Canonical Ltd.
/*
* Tests for AMF Configuration Factory
*/

package factory

import (
"fmt"
"testing"

"github.com/stretchr/testify/assert"
)

// Webui URL is not set then default Webui URL value is returned
func TestGetDefaultWebuiUrl(t *testing.T) {
if err := InitConfigFactory("../amfTest/amfcfg.yaml"); err != nil {
fmt.Printf("Error in InitConfigFactory: %v\n", err)
}
got := AmfConfig.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("../amfTest/amfcfg_with_custom_webui_url.yaml"); err != nil {
fmt.Printf("Error in InitConfigFactory: %v\n", err)
}
got := AmfConfig.Configuration.WebuiUri
want := "myspecialwebui:9872"
assert.Equal(t, got, want, "The webui URL is not correct.")
}

0 comments on commit 538564c

Please sign in to comment.