Improving Coverage at Config

This commit is contained in:
arberkatellari
2022-11-18 19:23:50 -05:00
committed by Dan Christian Bogos
parent fd0bec2e10
commit 4a01e20569
2 changed files with 61 additions and 0 deletions

View File

@@ -371,3 +371,26 @@ func TestActionSCloneSection(t *testing.T) {
t.Errorf("Expected %v \n but received \n %v", exp, actCfg)
}
}
func TestDiffActionsOptsJsonCfg(t *testing.T) {
d := &ActionsOptsJson{}
v1 := &ActionsOpts{
PosterAttempts: []*utils.DynamicIntOpt{},
}
v2 := &ActionsOpts{
PosterAttempts: []*utils.DynamicIntOpt{{
FilterIDs: []string{"fltr1"},
},
},
}
exp := &ActionsOptsJson{
PosterAttempts: []*utils.DynamicIntOpt{{
FilterIDs: []string{"fltr1"},
},
},
}
if rcv := diffActionsOptsJsonCfg(d, v1, v2); utils.ToJSON(rcv) != utils.ToJSON(exp) {
t.Errorf("Expected <%v> \n Received \n <%v>", exp, rcv)
}
}

View File

@@ -204,3 +204,41 @@ func TestAnalyzerSCloneSection(t *testing.T) {
t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(exp), utils.ToJSON(anlCfg))
}
}
// //unfinished
// func TestToLoadFromJSONCfg(t *testing.T) {
// anzOpts := &AnalyzerSOpts{
// ExporterIDs: []*utils.DynamicStringSliceOpt{
// {
// FilterIDs: []string{"filtr1"},
// },
// },
// }
// var jsonAnzOpts *AnalyzerSOptsJson
// anzOpts.loadFromJSONCfg(jsonAnzOpts)
// }
func TestDiffAnalyzerSOptsJsonCfg(t *testing.T) {
d := &AnalyzerSOptsJson{}
v1 := &AnalyzerSOpts{
ExporterIDs: []*utils.DynamicStringSliceOpt{},
}
v2 := &AnalyzerSOpts{
ExporterIDs: []*utils.DynamicStringSliceOpt{{
FilterIDs: []string{"test"},
},
},
}
exp := &AnalyzerSOptsJson{
ExporterIDs: []*utils.DynamicStringSliceOpt{{
FilterIDs: []string{"test"},
},
},
}
if rcv := diffAnalyzerSOptsJsonCfg(d, v1, v2); utils.ToJSON(rcv) != utils.ToJSON(exp) {
t.Errorf("Expected <%v> \n Received \n <%v>", exp, rcv)
}
}