X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=cmd%2Fvesmgr%2Fconfig_test.go;h=7a07e38bcdc6544dfb24486c6564449ff6788164;hb=3e79fbe717397e8996b1c58989750012cb0e767f;hp=76793a12176566198908ad8028bdd46167465cbf;hpb=fc77ebb24a8627ccfb18edd8b5dbc038da475eab;p=ric-plt%2Fvespamgr.git diff --git a/cmd/vesmgr/config_test.go b/cmd/vesmgr/config_test.go index 76793a1..7a07e38 100644 --- a/cmd/vesmgr/config_test.go +++ b/cmd/vesmgr/config_test.go @@ -34,6 +34,13 @@ func testBaseConf(t *testing.T, vesconf VESAgentConfiguration) { assert.Equal(t, vesconf.Event.MaxMissed, 2) assert.Equal(t, vesconf.Event.RetryInterval, time.Second*5) assert.Equal(t, vesconf.Measurement.Prometheus.KeepAlive, time.Second*30) + assert.Equal(t, vesconf.Event.VNFName, defaultVNFName) + assert.Equal(t, vesconf.Event.ReportingEntityName, "Vespa") + // depending on the credentials with which this test is run, + // root or non-root, the code either reads the UUID from the file or + // ends up using the default id. Just check the length here, + // not the actual value. + assert.Len(t, vesconf.Event.ReportingEntityID, len(defaultReportingEntityID)) } func TestBasicConfigContainsCorrectValues(t *testing.T) { @@ -41,7 +48,15 @@ func TestBasicConfigContainsCorrectValues(t *testing.T) { testBaseConf(t, vesconf) } +func TestBasicConfigContainsCorrectVNFName(t *testing.T) { + os.Setenv("VESMGR_VNFNAME", "VNF-111") + vesconf := basicVespaConf() + assert.Equal(t, vesconf.Event.VNFName, "VNF-111") + os.Unsetenv("VESMGR_VNFNAME") +} + func TestCollectorConfiguration(t *testing.T) { + os.Unsetenv("VESMGR_VNFNAME") os.Setenv("VESMGR_PRICOLLECTOR_USER", "user123") os.Setenv("VESMGR_PRICOLLECTOR_PASSWORD", "pass123") os.Setenv("VESMGR_PRICOLLECTOR_PASSPHRASE", "phrase123") @@ -65,6 +80,7 @@ func TestCollectorConfiguration(t *testing.T) { } func TestCollectorConfigurationWhenEnvironmentVariablesAreNotDefined(t *testing.T) { + os.Unsetenv("VESMGR_VNFNAME") os.Unsetenv("VESMGR_PRICOLLECTOR_USER") os.Unsetenv("VESMGR_PRICOLLECTOR_PASSWORD") os.Unsetenv("VESMGR_PRICOLLECTOR_PASSPHRASE")