Commit 087a6f56 authored by Cristian Maglie's avatar Cristian Maglie

Fixed FindConfigFileInArgsFallbackOnEnv unit test

parent 61b66a70
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package configuration package configuration
import ( import (
"path/filepath"
"testing" "testing"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
...@@ -41,8 +42,9 @@ func TestInit(t *testing.T) { ...@@ -41,8 +42,9 @@ func TestInit(t *testing.T) {
} }
func TestFindConfigFile(t *testing.T) { func TestFindConfigFile(t *testing.T) {
defaultConfigFile := filepath.Join(getDefaultArduinoDataDir(), "arduino-cli.yaml")
configFile := FindConfigFileInArgsFallbackOnEnv([]string{"--config-file"}) configFile := FindConfigFileInArgsFallbackOnEnv([]string{"--config-file"})
require.Equal(t, "", configFile) require.Equal(t, defaultConfigFile, configFile)
configFile = FindConfigFileInArgsFallbackOnEnv([]string{"--config-file", "some/path/to/config"}) configFile = FindConfigFileInArgsFallbackOnEnv([]string{"--config-file", "some/path/to/config"})
require.Equal(t, "some/path/to/config", configFile) require.Equal(t, "some/path/to/config", configFile)
...@@ -51,7 +53,7 @@ func TestFindConfigFile(t *testing.T) { ...@@ -51,7 +53,7 @@ func TestFindConfigFile(t *testing.T) {
require.Equal(t, "some/path/to/config/arduino-cli.yaml", configFile) require.Equal(t, "some/path/to/config/arduino-cli.yaml", configFile)
configFile = FindConfigFileInArgsFallbackOnEnv([]string{}) configFile = FindConfigFileInArgsFallbackOnEnv([]string{})
require.Equal(t, "", configFile) require.Equal(t, defaultConfigFile, configFile)
t.Setenv("ARDUINO_CONFIG_FILE", "some/path/to/config") t.Setenv("ARDUINO_CONFIG_FILE", "some/path/to/config")
configFile = FindConfigFileInArgsFallbackOnEnv([]string{}) configFile = FindConfigFileInArgsFallbackOnEnv([]string{})
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment