From ea06b5ef97df96f8a98556eea4ebe4357bdba3c4 Mon Sep 17 00:00:00 2001 From: dido18 Date: Fri, 24 Oct 2025 16:59:48 +0200 Subject: [PATCH 1/3] fix(app): improve error messages for invalid app paths in Load function --- internal/orchestrator/app/app.go | 2 +- internal/orchestrator/app/app_test.go | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/internal/orchestrator/app/app.go b/internal/orchestrator/app/app.go index 165b0062..c40c9009 100644 --- a/internal/orchestrator/app/app.go +++ b/internal/orchestrator/app/app.go @@ -48,7 +48,7 @@ func Load(appPath string) (ArduinoApp, error) { return ArduinoApp{}, fmt.Errorf("app path is not valid: %w", err) } if !exist { - return ArduinoApp{}, fmt.Errorf("no such file or directory: %s", path) + return ArduinoApp{}, fmt.Errorf("app path must be a directory: %s", path) } path, err = path.Abs() if err != nil { diff --git a/internal/orchestrator/app/app_test.go b/internal/orchestrator/app/app_test.go index 1256c648..c2a56a22 100644 --- a/internal/orchestrator/app/app_test.go +++ b/internal/orchestrator/app/app_test.go @@ -25,13 +25,26 @@ import ( ) func TestLoad(t *testing.T) { - t.Run("empty", func(t *testing.T) { + t.Run("empty path returns an error", func(t *testing.T) { app, err := Load("") assert.Error(t, err) assert.Empty(t, app) + assert.Contains(t, err.Error(), "empty") }) - t.Run("AppSimple", func(t *testing.T) { + t.Run("it fails if the app path is an existing file", func(t *testing.T) { + _, err := Load("testdata/app.yaml") + assert.Error(t, err) + assert.Contains(t, err.Error(), "app path must be a directory") + }) + + t.Run("it fails if the app path does not exist", func(t *testing.T) { + _, err := Load("testdata/this-folder-does-not-exist") + assert.Error(t, err) + assert.Contains(t, err.Error(), "app path is not valid") + }) + + t.Run("it load an app correctly", func(t *testing.T) { app, err := Load("testdata/AppSimple") assert.NoError(t, err) assert.NotEmpty(t, app) From c60ecc100f5b9477898ab4a407efff873f8560b0 Mon Sep 17 00:00:00 2001 From: dido18 Date: Fri, 24 Oct 2025 17:27:40 +0200 Subject: [PATCH 2/3] fix(tests): improve test descriptions and error messages in TestLoad --- internal/orchestrator/app/app_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/orchestrator/app/app_test.go b/internal/orchestrator/app/app_test.go index c2a56a22..f6327df7 100644 --- a/internal/orchestrator/app/app_test.go +++ b/internal/orchestrator/app/app_test.go @@ -25,14 +25,14 @@ import ( ) func TestLoad(t *testing.T) { - t.Run("empty path returns an error", func(t *testing.T) { + t.Run("it fails if tha app path is empty", func(t *testing.T) { app, err := Load("") assert.Error(t, err) assert.Empty(t, app) - assert.Contains(t, err.Error(), "empty") + assert.Contains(t, err.Error(), "empty app path") }) - t.Run("it fails if the app path is an existing file", func(t *testing.T) { + t.Run("it fails if the app path exist but it's a file", func(t *testing.T) { _, err := Load("testdata/app.yaml") assert.Error(t, err) assert.Contains(t, err.Error(), "app path must be a directory") @@ -44,7 +44,7 @@ func TestLoad(t *testing.T) { assert.Contains(t, err.Error(), "app path is not valid") }) - t.Run("it load an app correctly", func(t *testing.T) { + t.Run("it loads an app correctly", func(t *testing.T) { app, err := Load("testdata/AppSimple") assert.NoError(t, err) assert.NotEmpty(t, app) From 094b60ff5d5ef9853077c9bcf35fa1d6f083e5ae Mon Sep 17 00:00:00 2001 From: Davide Date: Wed, 29 Oct 2025 10:05:12 +0100 Subject: [PATCH 3/3] Update internal/orchestrator/app/app_test.go Co-authored-by: mirkoCrobu --- internal/orchestrator/app/app_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/orchestrator/app/app_test.go b/internal/orchestrator/app/app_test.go index f6327df7..47e3f53f 100644 --- a/internal/orchestrator/app/app_test.go +++ b/internal/orchestrator/app/app_test.go @@ -25,7 +25,7 @@ import ( ) func TestLoad(t *testing.T) { - t.Run("it fails if tha app path is empty", func(t *testing.T) { + t.Run("it fails if the app path is empty", func(t *testing.T) { app, err := Load("") assert.Error(t, err) assert.Empty(t, app)