Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
MKCLOS
Core Development Platform
corepkgv2
Commits
cd03ce71
Commit
cd03ce71
authored
6 years ago
by
Roshan Patil
Browse files
Options
Downloads
Patches
Plain Diff
mongoDB test commentd
parent
8f9d45d1
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!34
Devbranch to Master
,
!25
testing Data enhancement
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dalmdl/mongodb/mongodb_test.go
+42
-50
dalmdl/mongodb/mongodb_test.go
with
42 additions
and
50 deletions
dalmdl/mongodb/mongodb_test.go
+
42
−
50
View file @
cd03ce71
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")
//
}
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets