From 80153ef87379040ff1c9ac6f11a7063b743a3fb2 Mon Sep 17 00:00:00 2001 From: Mukul Rawat Date: Tue, 16 Oct 2018 03:36:46 +0530 Subject: [MM-12362] Add CLI command 'config show' (#9536) (#9564) * Add the subcommand by creating a new Command instance. * Implemented the structure of the subcommand function. * Register our new command * Write some helper functions * finish the pretty print function * write some test for config show * Refactor and extract the tab printing functionality in its own function * Use app.Config() to create our config object & accept incoming changes * Removed reading the file, make helper functions return string and perform printing inside the command * Remove the previous code for checking presence of arguments and use 'cobra.NoArgs()' instead * Remove named return and instead declare the variable and then return it. * Remove printTab function and simplify printing out tabs using strings.Repeat * Add some functions to test the output * Update the usage and remove a comment * Update the print --- cmd/mattermost/commands/config_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'cmd/mattermost/commands/config_test.go') diff --git a/cmd/mattermost/commands/config_test.go b/cmd/mattermost/commands/config_test.go index a68818201..02178c770 100644 --- a/cmd/mattermost/commands/config_test.go +++ b/cmd/mattermost/commands/config_test.go @@ -401,5 +401,20 @@ func TestPrintConfigValues(t *testing.T) { } }) } +} + +func TestConfigShow(t *testing.T) { + + // error + assert.Error(t, RunCommand(t, "config", "show", "abc")) + + // no error + assert.NoError(t, RunCommand(t, "config", "show")) + + // check the output + output := CheckCommand(t, "config", "show") + assert.Contains(t, string(output), "SqlSettings") + assert.Contains(t, string(output), "MessageExportSettings") + assert.Contains(t, string(output), "AnnouncementSettings") } -- cgit v1.2.3-1-g7c22