@@ -3,9 +3,7 @@ package config
3
3
import (
4
4
"os"
5
5
"testing"
6
- "time"
7
6
8
- "github.com/arduino/go-paths-helper"
9
7
"github.com/stretchr/testify/assert"
10
8
)
11
9
@@ -36,40 +34,40 @@ func TestGetConfigPathFromARDUINO_CREATE_AGENT_CONFIG(t *testing.T) {
36
34
assert .Equal (t , "./testdata/fromenv/config.ini" , configPath .String ())
37
35
}
38
36
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
+ // }
65
53
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
+ // }
68
59
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
+ // }
73
71
74
72
// func TestGetConfigPathCreateDefaultConfig(t *testing.T) {
75
73
// os.Setenv("HOME", "./testdata/noconfig")
0 commit comments