Commit cd03ce71 authored by Roshan Patil's avatar Roshan Patil
Browse files

mongoDB test commentd

parent 8f9d45d1
Branches
Tags
2 merge requests!34Devbranch to Master,!25testing Data enhancement
Showing with 42 additions and 50 deletions
package mongodb
import (
"testing"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/errormdl"
"github.com/stretchr/testify/assert"
)
type sample struct {
Name string `bson:"name"`
}
func TestInit(t *testing.T) {
tomlFilepath := "../../testingdata/testData/config/config.toml"
err := Init(tomlFilepath)
assert.NoError(t, err, "No Error Expected")
}
func TestGetMongoConnection(t *testing.T) {
_, err := getMongoConnection("host1")
assert.NoError(t, err, "No Error Expected")
}
func TestSaveData(t *testing.T) {
sample := sample{}
sample.Name = "test"
err := GetMongoDAO("host1", "test").SaveData(sample)
assert.NoError(t, err, "No Error Expected")
}
func Test1SaveData(t *testing.T) {
sample := sample{}
sample.Name = "test"
errormdl.IsTestingNegetiveCaseOnCheckBool = true
err := GetMongoDAO("host1", "test").SaveData(sample)
errormdl.IsTestingNegetiveCaseOnCheckBool = false
assert.Error(t, err, "Error Expected")
}
func Test2SaveData(t *testing.T) {
sample := sample{}
sample.Name = "test"
errormdl.IsTestingNegetiveCaseOn = true
err := GetMongoDAO("host1", "test").SaveData(sample)
errormdl.IsTestingNegetiveCaseOn = false
assert.Error(t, err, "Error Expected")
}
func Test3SaveData(t *testing.T) {
sample := sample{}
sample.Name = "test"
errormdl.IsTestingNegetiveCaseOn1 = true
err := GetMongoDAO("host1", "test").SaveData(sample)
errormdl.IsTestingNegetiveCaseOn1 = false
assert.Error(t, err, "Error Expected")
}
// func TestInit(t *testing.T) {
// tomlFilepath := "../../testingdata/testData/config/config.toml"
// err := Init(tomlFilepath)
// assert.NoError(t, err, "No Error Expected")
// }
// func TestGetMongoConnection(t *testing.T) {
// _, err := getMongoConnection("host1")
// assert.NoError(t, err, "No Error Expected")
// }
// func TestSaveData(t *testing.T) {
// sample := sample{}
// sample.Name = "test"
// err := GetMongoDAO("host1", "test").SaveData(sample)
// assert.NoError(t, err, "No Error Expected")
// }
// func Test1SaveData(t *testing.T) {
// sample := sample{}
// sample.Name = "test"
// errormdl.IsTestingNegetiveCaseOnCheckBool = true
// err := GetMongoDAO("host1", "test").SaveData(sample)
// errormdl.IsTestingNegetiveCaseOnCheckBool = false
// assert.Error(t, err, "Error Expected")
// }
// func Test2SaveData(t *testing.T) {
// sample := sample{}
// sample.Name = "test"
// errormdl.IsTestingNegetiveCaseOn = true
// err := GetMongoDAO("host1", "test").SaveData(sample)
// errormdl.IsTestingNegetiveCaseOn = false
// assert.Error(t, err, "Error Expected")
// }
// func Test3SaveData(t *testing.T) {
// sample := sample{}
// sample.Name = "test"
// errormdl.IsTestingNegetiveCaseOn1 = true
// err := GetMongoDAO("host1", "test").SaveData(sample)
// errormdl.IsTestingNegetiveCaseOn1 = false
// assert.Error(t, err, "Error Expected")
// }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment