aboutsummaryrefslogtreecommitdiffstats
path: root/src/k8splugin/vnfd/vnfd.go
diff options
context:
space:
mode:
authorVictor Morales <victor.morales@intel.com>2018-10-23 11:54:58 -0700
committerVictor Morales <victor.morales@intel.com>2018-11-13 16:20:57 -0800
commitcc05d4af8f082d8174bde5c43fc45b1acc61339f (patch)
treee5614b80fd1f4762c195eb26f639f7963eb2bb5f /src/k8splugin/vnfd/vnfd.go
parent7d2d48d3d0b35de0acd03c6e8a1261efd736edc3 (diff)
Create UTs to cover DB calls
This change pretends to increase the code coverage creating Unit Tests for the interactions with the Databases. Change-Id: I3b78ebe8ddb131e3c06bcee0065ad5eabeed5677 Signed-off-by: Victor Morales <victor.morales@intel.com> Issue-ID: MULTICLOUD-301
Diffstat (limited to 'src/k8splugin/vnfd/vnfd.go')
-rw-r--r--src/k8splugin/vnfd/vnfd.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/k8splugin/vnfd/vnfd.go b/src/k8splugin/vnfd/vnfd.go
index 322b2d78..0fb81dbd 100644
--- a/src/k8splugin/vnfd/vnfd.go
+++ b/src/k8splugin/vnfd/vnfd.go
@@ -67,7 +67,7 @@ func (v *VNFDefinitionClient) Create(vnfd VNFDefinition) (VNFDefinition, error)
return VNFDefinition{}, pkgerrors.Wrap(err, "Serialize VNF Definition")
}
- err = db.DBconn.CreateEntry(key, serData)
+ err = db.DBconn.Create(key, serData)
if err != nil {
return VNFDefinition{}, pkgerrors.Wrap(err, "Creating DB Entry")
}
@@ -85,12 +85,12 @@ func (v *VNFDefinitionClient) List() ([]VNFDefinition, error) {
var retData []VNFDefinition
for _, key := range strArray {
- value, ok, err := db.DBconn.ReadEntry(key)
+ value, err := db.DBconn.Read(key)
if err != nil {
log.Printf("Error Reading Key: %s", key)
continue
}
- if ok {
+ if value != "" {
vnfd := VNFDefinition{}
err = db.DeSerialize(value, &vnfd)
if err != nil {
@@ -106,12 +106,12 @@ func (v *VNFDefinitionClient) List() ([]VNFDefinition, error) {
// Get returns the VNF Definition for corresponding ID
func (v *VNFDefinitionClient) Get(vnfID string) (VNFDefinition, error) {
- value, ok, err := db.DBconn.ReadEntry(v.keyPrefix + vnfID)
+ value, err := db.DBconn.Read(v.keyPrefix + vnfID)
if err != nil {
return VNFDefinition{}, pkgerrors.Wrap(err, "Get VNF Definitions")
}
- if ok {
+ if value != "" {
vnfd := VNFDefinition{}
err = db.DeSerialize(value, &vnfd)
if err != nil {
@@ -125,7 +125,7 @@ func (v *VNFDefinitionClient) Get(vnfID string) (VNFDefinition, error) {
// Delete deletes the VNF Definition from database
func (v *VNFDefinitionClient) Delete(vnfID string) error {
- err := db.DBconn.DeleteEntry(v.keyPrefix + vnfID)
+ err := db.DBconn.Delete(v.keyPrefix + vnfID)
if err != nil {
return pkgerrors.Wrap(err, "Delete VNF Definitions")
}