Skip to content

Commit

Permalink
feat(golang-rewrite): update PluginAdd function to return error when …
Browse files Browse the repository at this point in the history
…repo does not exist
  • Loading branch information
Stratus3D committed Feb 27, 2024
1 parent dc86a12 commit 6b68d7b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions plugins/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ func PluginAdd(config config.Config, pluginName, pluginUrl string) error {
URL: pluginUrl,
})

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

// TODO: Implement this function
return nil
}
Expand Down
7 changes: 7 additions & 0 deletions plugins/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"os"
"strings"
"testing"

"github.com/stretchr/testify/assert"
)

func TestPluginAdd(t *testing.T) {
Expand Down Expand Up @@ -49,6 +51,11 @@ func TestPluginAdd(t *testing.T) {
})

t.Run("when plugin name is valid but URL is invalid prints an error", func(t *testing.T) {
conf := config.Config{DataDir: testDataDir}

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

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 6b68d7b

Please sign in to comment.