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..47e3f53f 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("it fails if the 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 app path") }) - t.Run("AppSimple", 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") + }) + + 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 loads an app correctly", func(t *testing.T) { app, err := Load("testdata/AppSimple") assert.NoError(t, err) assert.NotEmpty(t, app)