Skip to content

Commit 9143b02

Browse files
committed
feat(config): skip tests if not linux
1 parent 29a1bf3 commit 9143b02

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

Diff for: config/config.go

+1
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ func SetInstallCertsIni(filename string, value string) error {
143143
return nil
144144
}
145145

146+
// GetConfigPath returns the path to the config file
146147
func GetConfigPath() *paths.Path {
147148
// Let's handle the config
148149
configDir := GetDefaultConfigDir()

Diff for: config/config_test.go renamed to config/config_linux_test.go

+19-1
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,42 @@ package config
22

33
import (
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
1113
func 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
1925
func 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
2837
func 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
4156
func 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

Comments
 (0)