9
9
"path/filepath"
10
10
"testing"
11
11
12
+ "github.com/adrg/xdg"
12
13
"github.com/stretchr/testify/assert"
13
14
"github.com/stretchr/testify/require"
14
15
@@ -83,6 +84,7 @@ func MockConfig(t *testing.T, cfg *config.Config) func() {
83
84
// Save original XDG_CONFIG_HOME
84
85
originalXDGConfigHome := os .Getenv ("XDG_CONFIG_HOME" )
85
86
t .Setenv ("XDG_CONFIG_HOME" , tempDir )
87
+ xdg .Reload ()
86
88
87
89
// Create the config directory structure
88
90
configDir := filepath .Join (tempDir , "toolhive" )
@@ -97,6 +99,7 @@ func MockConfig(t *testing.T, cfg *config.Config) func() {
97
99
98
100
return func () {
99
101
t .Setenv ("XDG_CONFIG_HOME" , originalXDGConfigHome )
102
+ xdg .Reload ()
100
103
}
101
104
}
102
105
@@ -226,31 +229,32 @@ func TestSuccessfulClientConfigOperations(t *testing.T) {
226
229
// Create test config files
227
230
createTestConfigFiles (t , tempHome )
228
231
229
- t .Run ("FindAllConfiguredClients" , func (t * testing.T ) { //nolint:paralleltest // Uses environment variables
230
- testConfig := & config.Config {
231
- Secrets : config.Secrets {
232
- ProviderType : "encrypted" ,
233
- },
234
- Clients : config.Clients {
235
- RegisteredClients : []string {
236
- string (VSCode ),
237
- string (VSCodeInsider ),
238
- string (Cursor ),
239
- string (RooCode ),
240
- string (ClaudeCode ),
241
- string (Cline ),
242
- string (AmpCli ),
243
- string (AmpVSCode ),
244
- string (AmpCursor ),
245
- string (AmpVSCodeInsider ),
246
- string (AmpWindsurf ),
247
- },
232
+ // Set up config for all sub-tests
233
+ testConfig := & config.Config {
234
+ Secrets : config.Secrets {
235
+ ProviderType : "encrypted" ,
236
+ },
237
+ Clients : config.Clients {
238
+ RegisteredClients : []string {
239
+ string (VSCode ),
240
+ string (VSCodeInsider ),
241
+ string (Cursor ),
242
+ string (RooCode ),
243
+ string (ClaudeCode ),
244
+ string (Cline ),
245
+ string (AmpCli ),
246
+ string (AmpVSCode ),
247
+ string (AmpCursor ),
248
+ string (AmpVSCodeInsider ),
249
+ string (AmpWindsurf ),
248
250
},
249
- }
251
+ },
252
+ }
250
253
251
- cleanup := MockConfig (t , testConfig )
252
- defer cleanup ()
254
+ cleanup := MockConfig (t , testConfig )
255
+ defer cleanup ()
253
256
257
+ t .Run ("FindAllConfiguredClients" , func (t * testing.T ) { //nolint:paralleltest // Uses environment variables
254
258
configs , err := FindRegisteredClientConfigs ()
255
259
require .NoError (t , err )
256
260
assert .Len (t , configs , len (supportedClientIntegrations ), "Should find all mock client configs" )
0 commit comments