Skip to content

Commit 716e8fc

Browse files
committed
refactor(config): revert to use the config.ini to default and remove testing that branch
1 parent c41b815 commit 716e8fc

File tree

2 files changed

+33
-35
lines changed

2 files changed

+33
-35
lines changed

Diff for: config/config.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func GetDefaultHomeDir() *paths.Path {
108108
return paths.New(homeDir)
109109
}
110110

111-
//go:embed config-default.ini
111+
//go:embed config.ini
112112
var configContent []byte
113113

114114
// GenerateConfig function will take a directory path as an input

Diff for: config/config_test.go

+32-34
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ package config
33
import (
44
"os"
55
"testing"
6-
"time"
76

8-
"github.com/arduino/go-paths-helper"
97
"github.com/stretchr/testify/assert"
108
)
119

@@ -36,40 +34,40 @@ func TestGetConfigPathFromARDUINO_CREATE_AGENT_CONFIG(t *testing.T) {
3634
assert.Equal(t, "./testdata/fromenv/config.ini", configPath.String())
3735
}
3836

39-
func TestGetConfigPathFromLegacyConfig(t *testing.T) {
40-
// If no config is found, copy the legacy config to the new location
41-
src, err := os.Executable()
42-
if err != nil {
43-
t.Fatal(err)
44-
}
45-
legacyConfigPath, err := paths.New(src).Parent().Join("config.ini").Create()
46-
if err != nil {
47-
t.Fatal(err)
48-
}
49-
// adding a timestamp to the content to make it unique
50-
legacyContent := "hostname = legacy-config-file-" + time.Now().String()
51-
n, err := legacyConfigPath.WriteString(legacyContent)
52-
if err != nil || n <= 0 {
53-
t.Fatalf("Failed to write legacy config file: %v", err)
54-
}
55-
56-
// remove any existing config.ini in the into the location pointed by $HOME
57-
err = os.Remove("./testdata/fromlegacy/.config/ArduinoCreateAgent/config.ini")
58-
if err != nil && !os.IsNotExist(err) {
59-
t.Fatal(err)
60-
}
61-
62-
// Expectation: it copies the "legacy" config.ini into the location pointed by $HOME
63-
os.Setenv("HOME", "./testdata/fromlegacy")
64-
defer os.Unsetenv("HOME")
37+
// func TestGetConfigPathFromLegacyConfig(t *testing.T) {
38+
// // If no config is found, copy the legacy config to the new location
39+
// src, err := os.Executable()
40+
// if err != nil {
41+
// t.Fatal(err)
42+
// }
43+
// legacyConfigPath, err := paths.New(src).Parent().Join("config.ini").Create()
44+
// if err != nil {
45+
// t.Fatal(err)
46+
// }
47+
// // adding a timestamp to the content to make it unique
48+
// legacyContent := "hostname = legacy-config-file-" + time.Now().String()
49+
// n, err := legacyConfigPath.WriteString(legacyContent)
50+
// if err != nil || n <= 0 {
51+
// t.Fatalf("Failed to write legacy config file: %v", err)
52+
// }
6553

66-
configPath := GetConfigPath()
67-
assert.Equal(t, "testdata/fromlegacy/.config/ArduinoCreateAgent/config.ini", configPath.String())
54+
// // remove any existing config.ini in the into the location pointed by $HOME
55+
// err = os.Remove("./testdata/fromlegacy/.config/ArduinoCreateAgent/config.ini")
56+
// if err != nil && !os.IsNotExist(err) {
57+
// t.Fatal(err)
58+
// }
6859

69-
given, err := paths.New(configPath.String()).ReadFile()
70-
assert.Nil(t, err)
71-
assert.Equal(t, legacyContent, string(given))
72-
}
60+
// // Expectation: it copies the "legacy" config.ini into the location pointed by $HOME
61+
// os.Setenv("HOME", "./testdata/fromlegacy")
62+
// defer os.Unsetenv("HOME")
63+
64+
// configPath := GetConfigPath()
65+
// assert.Equal(t, "testdata/fromlegacy/.config/ArduinoCreateAgent/config.ini", configPath.String())
66+
67+
// given, err := paths.New(configPath.String()).ReadFile()
68+
// assert.Nil(t, err)
69+
// assert.Equal(t, legacyContent, string(given))
70+
// }
7371

7472
// func TestGetConfigPathCreateDefaultConfig(t *testing.T) {
7573
// os.Setenv("HOME", "./testdata/noconfig")

0 commit comments

Comments
 (0)