config: remove test cases for impossible scenarios

AEInterval is overridden by NonUserSource, so there is no way for a user
to set this value. These two cases represented impossible real world
scenarios.

Instead the test is replaced with one that shows that the AEInterval can
not be set by config.

This change allows us to remove the hcltail and jsontail fields from
testCase
This commit is contained in:
Daniel Nephin 2020-12-21 18:20:43 -05:00
parent 76787d4dd0
commit f86ceea803

View File

@ -39,16 +39,14 @@ type testCase struct {
desc string desc string
args []string args []string
pre func() // setup(t *testing.T) pre func() // setup(t *testing.T)
json []string
hcl []string
patch func(rt *RuntimeConfig) // expected patch func(rt *RuntimeConfig) // expected
err string // expectedErr err string // expectedErr
warns []string // expectedWarnings warns []string // expectedWarnings
opts LoadOpts opts LoadOpts
// TODO: move all of these to opts json []string
hcltail, jsontail []string hcl []string
} }
// TestConfigFlagsAndEdgecases tests the command line flags and // TestConfigFlagsAndEdgecases tests the command line flags and
@ -1720,18 +1718,14 @@ func TestLoad_IntegrationWithFlags(t *testing.T) {
err: "Multiple public IPv6 addresses found. Please configure one", err: "Multiple public IPv6 addresses found. Please configure one",
}, },
{ {
desc: "ae_interval invalid == 0", desc: "ae_interval is overridden by NonUserSource",
args: []string{`-data-dir=` + dataDir}, args: []string{`-data-dir=` + dataDir},
jsontail: []string{`{ "ae_interval": "0s" }`}, json: []string{`{ "ae_interval": "-1s" }`},
hcltail: []string{`ae_interval = "0s"`}, hcl: []string{`ae_interval = "-1s"`},
err: `ae_interval cannot be 0s. Must be positive`, patch: func(rt *RuntimeConfig) {
rt.DataDir = dataDir
rt.AEInterval = time.Minute
}, },
{
desc: "ae_interval invalid < 0",
args: []string{`-data-dir=` + dataDir},
jsontail: []string{`{ "ae_interval": "-1s" }`},
hcltail: []string{`ae_interval = "-1s"`},
err: `ae_interval cannot be -1s. Must be positive`,
}, },
{ {
desc: "acl_datacenter invalid", desc: "acl_datacenter invalid",
@ -4876,9 +4870,10 @@ func testConfig(t *testing.T, tests []testCase, dataDir string) {
t.Fatal(tt.desc, ": JSON and HCL test case out of sync") t.Fatal(tt.desc, ": JSON and HCL test case out of sync")
} }
srcs, tails := tt.json, tt.jsontail // select the source
srcs := tt.json
if format == "hcl" { if format == "hcl" {
srcs, tails = tt.hcl, tt.hcltail srcs = tt.hcl
} }
// build the description // build the description
@ -4914,13 +4909,6 @@ func testConfig(t *testing.T, tests []testCase, dataDir string) {
Data: data, Data: data,
}) })
} }
for i, data := range tails {
b.Tail = append(b.Tail, FileSource{
Name: fmt.Sprintf("tail-%d.%s", i, format),
Format: format,
Data: data,
})
}
actual, err := b.BuildAndValidate() actual, err := b.BuildAndValidate()
switch { switch {