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

Function TestParseCommandLineWithBadConfigContent

rest/config_test.go:857–878  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

855}
856
857func TestParseCommandLineWithBadConfigContent(t *testing.T) {
858 content := `{"adminInterface":"127.0.0.1:4985","interface":"0.0.0.0:4984",
859 "databases":{"db":{"unknown_field":"walrus:data","users":{"GUEST":{"disabled":false,
860 "admin_channels":["*"]}}, "allow_conflicts":false,"revs_limit":20}}}`
861
862 configFile, err := os.CreateTemp("", "sync_gateway.conf")
863 configFileName := configFile.Name()
864 require.NoError(t, err, "Couldn't create configuration file")
865 _, err = configFile.Write([]byte(content))
866 assert.NoError(t, err, "Writing JSON content")
867
868 defer func() {
869 assert.NoError(t, configFile.Close(), "Couldn't close file: %v ", configFileName)
870 assert.NoError(t, os.Remove(configFileName), "Couldn't remove file: %v ", configFileName)
871 assert.False(t, base.FileExists(configFileName), "File %v should be removed", configFileName)
872 }()
873
874 args := []string{"sync_gateway", configFile.Name()}
875 config, err := ParseCommandLine(base.TestCtx(t), args, flag.ContinueOnError)
876 assert.Error(t, err, "Parsing configuration file with an unknown field")
877 assert.Nil(t, config)
878}
879
880func TestParseCommandLineWithConfigContent(t *testing.T) {
881 content := `{"logging":{"log_file_path":"/var/tmp/sglogs","console":{"log_level":"debug","log_keys":["*"]},

Callers

nothing calls this directly

Calls 8

FileExistsFunction · 0.92
TestCtxFunction · 0.92
ParseCommandLineFunction · 0.85
NameMethod · 0.65
CloseMethod · 0.65
RemoveMethod · 0.65
WriteMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected