@@ -2,30 +2,42 @@ package config
22
33import (
44 "os"
5+ "runtime"
56 "testing"
67
78 "github.com/arduino/go-paths-helper"
89 "github.com/stretchr/testify/assert"
910)
1011
12+ // TestGetConfigPathFromXDG_CONFIG_HOME tests the case when the config.ini is read from XDG_CONFIG_HOME/ArduinoCreateAgent/config.ini
1113func TestGetConfigPathFromXDG_CONFIG_HOME (t * testing.T ) {
14+ if runtime .GOOS != "linux" {
15+ t .Skip ("Skipping test on non-linux OS" )
16+ }
1217 // read config from $XDG_CONFIG_HOME/ArduinoCreateAgent/config.ini
1318 os .Setenv ("XDG_CONFIG_HOME" , "./testdata/fromxdghome" )
1419 defer os .Unsetenv ("XDG_CONFIG_HOME" )
1520 configPath := GetConfigPath ()
1621 assert .Equal (t , "testdata/fromxdghome/ArduinoCreateAgent/config.ini" , configPath .String ())
1722}
1823
24+ // TestGetConfigPathFromHOME tests the case when the config.ini is read from $HOME/.config/ArduinoCreateAgent/config.ini
1925func TestGetConfigPathFromHOME (t * testing.T ) {
20- // Test case 2: read config from $HOME/.config/ArduinoCreateAgent/config.ini "
26+ if runtime .GOOS != "linux" {
27+ t .Skip ("Skipping test on non-linux OS" )
28+ }
2129 os .Setenv ("HOME" , "./testdata/fromhome" )
2230 defer os .Unsetenv ("HOME" )
2331 configPath := GetConfigPath ()
2432 assert .Equal (t , "testdata/fromhome/.config/ArduinoCreateAgent/config.ini" , configPath .String ())
2533
2634}
2735
36+ // TestGetConfigPathFromARDUINO_CREATE_AGENT_CONFIG tests the case when the config.ini is read from ARDUINO_CREATE_AGENT_CONFIG env variable
2837func TestGetConfigPathFromARDUINO_CREATE_AGENT_CONFIG (t * testing.T ) {
38+ if runtime .GOOS != "linux" {
39+ t .Skip ("Skipping test on non-linux OS" )
40+ }
2941 // $HOME must be always set, otherwise panic
3042 os .Setenv ("HOME" , "./testdata/dummyhome" )
3143
@@ -34,11 +46,17 @@ func TestGetConfigPathFromARDUINO_CREATE_AGENT_CONFIG(t *testing.T) {
3446
3547 configPath := GetConfigPath ()
3648 assert .Equal (t , "./testdata/from-arduino-create-agent-config-env/config.ini" , configPath .String ())
49+
3750}
3851
52+ // TestIfHomeDoesNotContainConfigTheDefaultConfigAreCopied tests the case when the default config.ini is copied into $HOME/.config/ArduinoCreateAgent/config.ini
53+ // from the default config.ini
3954// If the ARDUINO_CREATE_AGENT_CONFIG is NOT set and the config.ini does not exist in HOME directory
4055// then it copies the default config (the config.ini) into the HOME directory
4156func TestIfHomeDoesNotContainConfigTheDefaultConfigAreCopied (t * testing.T ) {
57+ if runtime .GOOS != "linux" {
58+ t .Skip ("Skipping test on non-linux OS" )
59+ }
4260 // $HOME must be always set, otherwise panic
4361 os .Setenv ("HOME" , "./testdata/home-without-config" )
4462
0 commit comments