Use spiffy new Go 1.8 subtest feature
This commit is contained in:
parent
3e8dd386ee
commit
4910f867e7
|
@ -229,7 +229,9 @@ func TestConsulScript_Exec_Shutdown(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestConsulScript_Exec_Codes(t *testing.T) {
|
func TestConsulScript_Exec_Codes(t *testing.T) {
|
||||||
run := func(code int, err error, expected string) {
|
run := func(code int, err error, expected string) func(t *testing.T) {
|
||||||
|
return func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
serviceCheck := structs.ServiceCheck{
|
serviceCheck := structs.ServiceCheck{
|
||||||
Name: "test",
|
Name: "test",
|
||||||
Interval: time.Hour,
|
Interval: time.Hour,
|
||||||
|
@ -260,17 +262,18 @@ func TestConsulScript_Exec_Codes(t *testing.T) {
|
||||||
t.Fatalf("timed out waiting for script check to exec")
|
t.Fatalf("timed out waiting for script check to exec")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Test exit codes with errors
|
// Test exit codes with errors
|
||||||
run(0, nil, api.HealthPassing)
|
t.Run("Passing", run(0, nil, api.HealthPassing))
|
||||||
run(1, nil, api.HealthWarning)
|
t.Run("Warning", run(1, nil, api.HealthWarning))
|
||||||
run(2, nil, api.HealthCritical)
|
t.Run("Critical-2", run(2, nil, api.HealthCritical))
|
||||||
run(9000, nil, api.HealthCritical)
|
t.Run("Critical-9000", run(9000, nil, api.HealthCritical))
|
||||||
|
|
||||||
// Errors should always cause Critical status
|
// Errors should always cause Critical status
|
||||||
err := fmt.Errorf("test error")
|
err := fmt.Errorf("test error")
|
||||||
run(0, err, api.HealthCritical)
|
t.Run("Error-0", run(0, err, api.HealthCritical))
|
||||||
run(1, err, api.HealthCritical)
|
t.Run("Error-1", run(1, err, api.HealthCritical))
|
||||||
run(2, err, api.HealthCritical)
|
t.Run("Error-2", run(2, err, api.HealthCritical))
|
||||||
run(9000, err, api.HealthCritical)
|
t.Run("Error-9000", run(9000, err, api.HealthCritical))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue