@@ -89,12 +89,10 @@ func TestLoadFile(t *testing.T) {
8989
9090 require .NoError (t , err )
9191 require .Equal (t , testConf , string (content ))
92-
9392}
9493
9594// Checks if the env var substitution is happening correctly in the loaded file
9695func TestEnvSubstitution (t * testing.T ) {
97-
9896 config := "user: $(JA_USER)"
9997 os .Setenv ("JA_USER" , "user" )
10098
@@ -106,7 +104,6 @@ func TestEnvSubstitution(t *testing.T) {
106104 config = "user: $(JA_MISSING)"
107105 _ , err = substituteEnvVars ([]byte (config ), log .NewNopLogger ())
108106 require .Error (t , err )
109-
110107}
111108
112109// A test version of the ReceiverConfig struct to create test yaml fixtures.
@@ -186,7 +183,6 @@ func TestRequiredReceiverConfigKeys(t *testing.T) {
186183 }
187184 configErrorTestRunner (t , config , test .errorMessage )
188185 }
189-
190186}
191187
192188// Auth keys error scenarios.
@@ -352,7 +348,6 @@ func TestReceiverOverrides(t *testing.T) {
352348 configValue := reflect .ValueOf (receiver ).Elem ().FieldByName (test .overrideField ).Interface ()
353349 require .Equal (t , configValue , test .expectedValue )
354350 }
355-
356351}
357352
358353// TODO(bwplotka, rporres). Add more tests:
@@ -366,11 +361,12 @@ func newReceiverTestConfig(mandatory []string, optional []string) *receiverTestC
366361
367362 for _ , name := range mandatory {
368363 var value reflect.Value
369- if name == "APIURL" {
364+ switch name {
365+ case "APIURL" :
370366 value = reflect .ValueOf ("https://jiralert.atlassian.net" )
371- } else if name == "ReopenDuration" {
367+ case "ReopenDuration" :
372368 value = reflect .ValueOf ("30d" )
373- } else {
369+ default :
374370 value = reflect .ValueOf (name )
375371 }
376372
@@ -379,11 +375,12 @@ func newReceiverTestConfig(mandatory []string, optional []string) *receiverTestC
379375
380376 for _ , name := range optional {
381377 var value reflect.Value
382- if name == "AddGroupLabels" {
378+ switch name {
379+ case "AddGroupLabels" :
383380 value = reflect .ValueOf (true )
384- } else if name == "AutoResolve" {
381+ case "AutoResolve" :
385382 value = reflect .ValueOf (& AutoResolve {State : "Done" })
386- } else {
383+ default :
387384 value = reflect .ValueOf (name )
388385 }
389386
@@ -418,8 +415,10 @@ func removeFromStrSlice(strSlice []string, element string) []string {
418415// Returns mandatory receiver fields to be used creating test config structs.
419416// It does not include PAT auth, those tests will be created separately.
420417func mandatoryReceiverFields () []string {
421- return []string {"Name" , "APIURL" , "User" , "Password" , "Project" ,
422- "IssueType" , "Summary" , "ReopenState" , "ReopenDuration" }
418+ return []string {
419+ "Name" , "APIURL" , "User" , "Password" , "Project" ,
420+ "IssueType" , "Summary" , "ReopenState" , "ReopenDuration" ,
421+ }
423422}
424423
425424func TestAutoResolveConfigReceiver (t * testing.T ) {
@@ -439,7 +438,6 @@ func TestAutoResolveConfigReceiver(t *testing.T) {
439438 }
440439
441440 configErrorTestRunner (t , config , "bad config in receiver \" test\" , 'auto_resolve' was defined with empty 'state' field" )
442-
443441}
444442
445443func TestAutoResolveConfigDefault (t * testing.T ) {
@@ -457,5 +455,4 @@ func TestAutoResolveConfigDefault(t *testing.T) {
457455 }
458456
459457 configErrorTestRunner (t , config , "bad config in defaults section: state cannot be empty" )
460-
461458}
0 commit comments