-
Notifications
You must be signed in to change notification settings - Fork 12
PMM-4879: defaults-file param #171
base: main
Are you sure you want to change the base?
Conversation
# Conflicts: # go.mod # go.sum
@@ -110,3 +113,63 @@ func TestReadFile(t *testing.T) { | |||
require.Empty(t, certificate) | |||
}) | |||
} | |||
|
|||
type cmdWithDefaultsApply struct { | |||
applyDefaultCalled bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
used for tests only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't use mock libraries?
|
||
cmd := &addMySQLCommand{} | ||
|
||
commands.ConfigureDefaults(file.Name(), cmd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci-lint] reported by reviewdog 🐶
Error return value of commands.ConfigureDefaults
is not checked (errcheck)
Password: "default-password", | ||
} | ||
|
||
commands.ConfigureDefaults(file.Name(), cmd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci-lint] reported by reviewdog 🐶
Error return value of commands.ConfigureDefaults
is not checked (errcheck)
Password: "default-password", | ||
} | ||
|
||
commands.ConfigureDefaults(file.Name(), cmd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci-lint] reported by reviewdog 🐶
Error return value of commands.ConfigureDefaults
is not checked (errcheck)
@@ -160,3 +162,92 @@ func TestRun(t *testing.T) { | |||
} | |||
}) | |||
} | |||
|
|||
func TestApplyDefaults(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci-lint] reported by reviewdog 🐶
Function 'TestApplyDefaults' is too long (86 > 60) (funlen)
@@ -69,6 +73,10 @@ type Command interface { | |||
Run() (Result, error) | |||
} | |||
|
|||
type ApplyDefaults interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci-lint] reported by reviewdog 🐶
exported type ApplyDefaults
should have comment or be unexported (golint)
} | ||
|
||
func TestConfigureDefaults(t *testing.T) { | ||
t.Run("ApplyDefaults is called if command supports it", func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci-lint] reported by reviewdog 🐶
Function TestConfigureDefaults has missing the call to method parallel in the test run (paralleltest)
assert.Equal(t, "toor", cmd.password) | ||
}) | ||
|
||
t.Run("ApplyDefaults is not called if pass is not setup", func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci-lint] reported by reviewdog 🐶
Function TestConfigureDefaults has missing the call to method parallel in the test run (paralleltest)
}) | ||
} | ||
|
||
func TestExpandPath(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci-lint] reported by reviewdog 🐶
Function TestExpandPath missing the call to method parallel (paralleltest)
} | ||
|
||
func TestExpandPath(t *testing.T) { | ||
t.Run("relative to userhome", func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci-lint] reported by reviewdog 🐶
Function TestExpandPath has missing the call to method parallel in the test run (paralleltest)
|
||
assert.Equal(t, usr.HomeDir, actual) | ||
}) | ||
t.Run("relative to userhome", func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci-lint] reported by reviewdog 🐶
Function TestExpandPath has missing the call to method parallel in the test run (paralleltest)
|
||
func TestConfigureDefaults(t *testing.T) { | ||
t.Run("ApplyDefaults is called if command supports it", func(t *testing.T) { | ||
file, e := os.Open("../testdata/.my.cnf") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BupycHuk you were asking for it. I use real file in cmd test, but tmp files for commands/management/add_mysql.go
@@ -160,3 +164,87 @@ func TestRun(t *testing.T) { | |||
} | |||
}) | |||
} | |||
|
|||
func TestApplyDefaults(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci-lint] reported by reviewdog 🐶
Function 'TestApplyDefaults' is too long (81 > 60) (funlen)
@@ -0,0 +1,5 @@ | |||
[client] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -184,6 +193,37 @@ func (e errFromNginx) GoString() string { | |||
return fmt.Sprintf("errFromNginx(%q)", string(e)) | |||
} | |||
|
|||
func ConfigureDefaults(config string, cmd ApplyDefaults) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think its better to rename it to configPath
"strings" | ||
"testing" | ||
|
||
"gopkg.in/ini.v1" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's remove this blank line
@@ -110,3 +113,63 @@ func TestReadFile(t *testing.T) { | |||
require.Empty(t, certificate) | |||
}) | |||
} | |||
|
|||
type cmdWithDefaultsApply struct { | |||
applyDefaultCalled bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't use mock libraries?
|
||
assert.Equal(t, usr.HomeDir, actual) | ||
}) | ||
t.Run("relative to userhome", func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it doesn't look relative to userhome
"github.com/sirupsen/logrus" | ||
|
||
"gopkg.in/ini.v1" | ||
|
||
"github.com/percona/pmm-admin/agentlocal" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please fix imports to split them in 3 blocks
- go libs
- 3rd party libs
- local packages
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here and in other files
Jira Ticket and related ticket
FB
commands.ApplyDefaults