Manually test different types of flags with invalid values
(t *testing.T)
| 121 | |
| 122 | // Manually test different types of flags with invalid values |
| 123 | func TestFillConfigWithFlagsInvalidVals(t *testing.T) { |
| 124 | fs := flag.NewFlagSet("test", flag.ContinueOnError) |
| 125 | config := NewEmptyStartupConfig() |
| 126 | |
| 127 | flags := registerConfigFlags(&config, fs) |
| 128 | |
| 129 | err := fs.Parse([]string{ |
| 130 | "-bootstrap.config_update_frequency", "time2h", // *base.ConfigDuration |
| 131 | "-logging.redaction_level", "redactnone", // RedactionLevel |
| 132 | "-logging.console.log_level", "wrn", // *LogLevel |
| 133 | "-replicator.max_heartbeat", "time5h2m", // base.ConfigDuration |
| 134 | "-bootstrap.server", "testServer", // String - filled valid so should not error |
| 135 | }) |
| 136 | require.NoError(t, err) |
| 137 | |
| 138 | err = fillConfigWithFlags(fs, flags) |
| 139 | require.Error(t, err) |
| 140 | |
| 141 | // Check each flag that has invalid value has error associated with it |
| 142 | assert.Contains(t, err.Error(), "bootstrap.config_update_frequency") |
| 143 | assert.Contains(t, err.Error(), "logging.redaction_level") |
| 144 | assert.Contains(t, err.Error(), "logging.console.log_level") |
| 145 | assert.Contains(t, err.Error(), "replicator.max_heartbeat") |
| 146 | |
| 147 | assert.NotContains(t, err.Error(), "bootstrap.server") |
| 148 | } |
| 149 | |
| 150 | // Make sure the number of config options and number of flags match |
| 151 | func TestAllConfigOptionsAsFlags(t *testing.T) { |
nothing calls this directly
no test coverage detected