mirror of https://github.com/status-im/consul.git
config: make TestLoad_IntegrationWithFlags easier to work with
Replace the large table of tests with individual calls to run(). By using runCase, failure messages will include the line number for the test case, as well as a line number from the test functions. Example: === FAIL: agent/config TestLoad_IntegrationWithFlags/failing_case (0.01s) runtime_test.go:4721: case: failing case runtime_test.go:4864: error "data_dir cannot be empty" does not contain "I expected this error" Previous: runtime_test.go:4864: error "data_dir cannot be empty" does not contain "I expected this error" Without the line number to the testCase data, debugging these tests is difficult. It is impossible to jump directly to the test case, and difficult to find the location because of many similarly named cases.
This commit is contained in:
parent
bd728df345
commit
534631659c
File diff suppressed because it is too large
Load Diff
|
@ -3,6 +3,7 @@
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/hashicorp/consul/sdk/testutil"
|
"github.com/hashicorp/consul/sdk/testutil"
|
||||||
|
@ -50,9 +51,10 @@ func TestSegments(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tc := range tests {
|
||||||
for _, format := range []string{"json", "hcl"} {
|
for _, format := range []string{"json", "hcl"} {
|
||||||
testConfig(t, tt, format, dataDir)
|
name := fmt.Sprintf("%v_%v", tc.desc, format)
|
||||||
|
t.Run(name, tc.run(format, dataDir))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue