Skip to content

Commit

Permalink
fix(golang-rewrite): address linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Stratus3D committed Feb 28, 2024
1 parent 7775663 commit c951220
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions plugins/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

const dataDirPlugins = "plugins"
const invalidPluginNameMsg = "'%q' is invalid. Name may only contain lowercase letters, numbers, '_', and '-'"
const pluginAlreadyExists = "Plugin named %q already added"
const pluginAlreadyExists = "plugin named %q already added"

func PluginAdd(config config.Config, pluginName, pluginUrl string) error {
err := validatePluginName(pluginName)
Expand All @@ -25,7 +25,7 @@ func PluginAdd(config config.Config, pluginName, pluginUrl string) error {
exists, err := PluginExists(config.DataDir, pluginName)

if err != nil {
return fmt.Errorf("Unable to check if plugin already exists: %w", err)
return fmt.Errorf("unable to check if plugin already exists: %w", err)
}

if exists {
Expand All @@ -35,15 +35,15 @@ func PluginAdd(config config.Config, pluginName, pluginUrl string) error {
pluginDir := PluginDirectory(config.DataDir, pluginName)

if err != nil {
return fmt.Errorf("Unable to create plugin directory: %w", err)
return fmt.Errorf("unable to create plugin directory: %w", err)
}

_, err = git.PlainClone(pluginDir, false, &git.CloneOptions{
URL: pluginUrl,
})

if err != nil {
return fmt.Errorf("Unable to clone plugin: %w", err)
return fmt.Errorf("unable to clone plugin: %w", err)
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions plugins/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestPluginAdd(t *testing.T) {
t.Fatal("expected error got nil")
}

expectedErrMsg := "Plugin named \"lua\" already added"
expectedErrMsg := "plugin named \"lua\" already added"
if !strings.Contains(err.Error(), expectedErrMsg) {
t.Errorf("Expected an error with message %v", expectedErrMsg)
}
Expand All @@ -61,7 +61,7 @@ func TestPluginAdd(t *testing.T) {

err := PluginAdd(conf, "foo", "foobar")

assert.ErrorContains(t, err, "Unable to clone plugin: repository not found")
assert.ErrorContains(t, err, "unable to clone plugin: repository not found")
})

t.Run("when plugin name and URL are valid installs plugin", func(t *testing.T) {
Expand Down

0 comments on commit c951220

Please sign in to comment.