Skip to content

Commit

Permalink
test(unit-tests): updating unit tests (#331) (#333)
Browse files Browse the repository at this point in the history
Signed-off-by: shubhamchaudhary <[email protected]>

Co-authored-by: Shubham Chaudhary <[email protected]>
  • Loading branch information
Karthik Satchitanand and ispeakc0de authored Feb 2, 2021
1 parent 349a577 commit 7d72b3e
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 76 deletions.
5 changes: 5 additions & 0 deletions pkg/controller/chaosengine/chaosengine_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1764,6 +1764,11 @@ func TestReconcileForCreationAndRunning(t *testing.T) {
Image: "fake-runner-image",
},
},
Experiments: []litmuschaosv1alpha1.ExperimentList{
{
Name: "exp-1",
},
},
},
},

Expand Down
152 changes: 76 additions & 76 deletions pkg/controller/resource/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -992,43 +992,7 @@ func TestCheckChaosAnnotationDeploymentConfigs(t *testing.T) {
isErr: false,
check: true,
},
"Test Negative-1": {
engine: chaosTypes.EngineInfo{
Instance: &litmuschaosv1alpha1.ChaosEngine{
ObjectMeta: metav1.ObjectMeta{
Name: "check-chaos-annotation-d3",
Namespace: "default",
},
Spec: litmuschaosv1alpha1.ChaosEngineSpec{
Appinfo: litmuschaosv1alpha1.ApplicationParams{
Applabel: "app=nginx3",
AppKind: "deploymentconfig",
},
EngineState: "active",
AnnotationCheck: "true",
Components: litmuschaosv1alpha1.ComponentParams{
Runner: litmuschaosv1alpha1.RunnerInfo{
Image: "fake-runner-image",
},
},
Experiments: []litmuschaosv1alpha1.ExperimentList{
{
Name: "exp-1",
},
},
},
},
AppInfo: &chaosTypes.ApplicationInfo{
Kind: "deploymentconfig",
Label: map[string]string{
"app": "nginx3",
},
},
},
isErr: true,
check: false,
},
"Test Negative-2": {
"Test Positive-3": {
engine: chaosTypes.EngineInfo{
Instance: &litmuschaosv1alpha1.ChaosEngine{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -1106,9 +1070,45 @@ func TestCheckChaosAnnotationDeploymentConfigs(t *testing.T) {
},
},

isErr: true,
isErr: false,
check: true,
},
"Test Negative-1": {
engine: chaosTypes.EngineInfo{
Instance: &litmuschaosv1alpha1.ChaosEngine{
ObjectMeta: metav1.ObjectMeta{
Name: "check-chaos-annotation-d3",
Namespace: "default",
},
Spec: litmuschaosv1alpha1.ChaosEngineSpec{
Appinfo: litmuschaosv1alpha1.ApplicationParams{
Applabel: "app=nginx3",
AppKind: "deploymentconfig",
},
EngineState: "active",
AnnotationCheck: "true",
Components: litmuschaosv1alpha1.ComponentParams{
Runner: litmuschaosv1alpha1.RunnerInfo{
Image: "fake-runner-image",
},
},
Experiments: []litmuschaosv1alpha1.ExperimentList{
{
Name: "exp-1",
},
},
},
},
AppInfo: &chaosTypes.ApplicationInfo{
Kind: "deploymentconfig",
Label: map[string]string{
"app": "nginx3",
},
},
},
isErr: true,
check: false,
},
}
for name, mock := range tests {
t.Run(name, func(t *testing.T) {
Expand Down Expand Up @@ -1282,43 +1282,7 @@ func TestCheckChaosAnnotationRollouts(t *testing.T) {
isErr: false,
check: true,
},
"Test Negative-1": {
engine: chaosTypes.EngineInfo{
Instance: &litmuschaosv1alpha1.ChaosEngine{
ObjectMeta: metav1.ObjectMeta{
Name: "check-chaos-annotation-d3",
Namespace: "default",
},
Spec: litmuschaosv1alpha1.ChaosEngineSpec{
Appinfo: litmuschaosv1alpha1.ApplicationParams{
Applabel: "app=nginx3",
AppKind: "rollout",
},
EngineState: "active",
AnnotationCheck: "true",
Components: litmuschaosv1alpha1.ComponentParams{
Runner: litmuschaosv1alpha1.RunnerInfo{
Image: "fake-runner-image",
},
},
Experiments: []litmuschaosv1alpha1.ExperimentList{
{
Name: "exp-1",
},
},
},
},
AppInfo: &chaosTypes.ApplicationInfo{
Kind: "rollout",
Label: map[string]string{
"app": "nginx3",
},
},
},
isErr: true,
check: false,
},
"Test Negative-2": {
"Test Positive-3": {
engine: chaosTypes.EngineInfo{
Instance: &litmuschaosv1alpha1.ChaosEngine{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -1400,9 +1364,45 @@ func TestCheckChaosAnnotationRollouts(t *testing.T) {
},
},

isErr: true,
isErr: false,
check: true,
},
"Test Negative-1": {
engine: chaosTypes.EngineInfo{
Instance: &litmuschaosv1alpha1.ChaosEngine{
ObjectMeta: metav1.ObjectMeta{
Name: "check-chaos-annotation-d3",
Namespace: "default",
},
Spec: litmuschaosv1alpha1.ChaosEngineSpec{
Appinfo: litmuschaosv1alpha1.ApplicationParams{
Applabel: "app=nginx3",
AppKind: "rollout",
},
EngineState: "active",
AnnotationCheck: "true",
Components: litmuschaosv1alpha1.ComponentParams{
Runner: litmuschaosv1alpha1.RunnerInfo{
Image: "fake-runner-image",
},
},
Experiments: []litmuschaosv1alpha1.ExperimentList{
{
Name: "exp-1",
},
},
},
},
AppInfo: &chaosTypes.ApplicationInfo{
Kind: "rollout",
Label: map[string]string{
"app": "nginx3",
},
},
},
isErr: true,
check: false,
},
}

for name, mock := range tests {
Expand Down

0 comments on commit 7d72b3e

Please sign in to comment.