MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / TestFillConfigWithFlagsInvalidVals

Function TestFillConfigWithFlagsInvalidVals

rest/config_flags_test.go:123–148  ·  view source on GitHub ↗

Manually test different types of flags with invalid values

(t *testing.T)

Source from the content-addressed store, hash-verified

121
122// Manually test different types of flags with invalid values
123func 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
151func TestAllConfigOptionsAsFlags(t *testing.T) {

Callers

nothing calls this directly

Calls 5

NewEmptyStartupConfigFunction · 0.85
registerConfigFlagsFunction · 0.85
fillConfigWithFlagsFunction · 0.85
ContainsMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected