From 6b68d7b3778202e0e9bf483cc806822de505d8d9 Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Tue, 27 Feb 2024 10:21:53 -0500 Subject: [PATCH] feat(golang-rewrite): update PluginAdd function to return error when repo does not exist --- plugins/main.go | 4 ++++ plugins/main_test.go | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/plugins/main.go b/plugins/main.go index 7d8daab0..ea3ef771 100644 --- a/plugins/main.go +++ b/plugins/main.go @@ -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 } diff --git a/plugins/main_test.go b/plugins/main_test.go index 90a6d865..c17e4a6e 100644 --- a/plugins/main_test.go +++ b/plugins/main_test.go @@ -5,6 +5,8 @@ import ( "os" "strings" "testing" + + "github.com/stretchr/testify/assert" ) func TestPluginAdd(t *testing.T) { @@ -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) {