@@ -346,21 +346,22 @@ func Test_StateDir(t *testing.T) {
346346 tempDir := t .TempDir ()
347347
348348 tests := []struct {
349- name string
350- env map [string ]string
351- output string
349+ name string
350+ onlyWindows bool
351+ env map [string ]string
352+ output string
352353 }{
353354 {
354355 name : "HOME/USERPROFILE specified" ,
355356 env : map [string ]string {
356357 "XDG_STATE_HOME" : "" ,
357358 "GH_CONFIG_DIR" : "" ,
358359 "XDG_CONFIG_HOME" : "" ,
359- "AppData" : "" ,
360+ "LocalAppData" : "" ,
360361 "USERPROFILE" : tempDir ,
361362 "HOME" : tempDir ,
362363 },
363- output : filepath .Join (tempDir , ".config " , "gh" ),
364+ output : filepath .Join (tempDir , ".local" , "state " , "gh" ),
364365 },
365366 {
366367 name : "XDG_STATE_HOME specified" ,
@@ -370,15 +371,28 @@ func Test_StateDir(t *testing.T) {
370371 output : filepath .Join (tempDir , "gh" ),
371372 },
372373 {
373- name : "GH_CONFIG_DIR specified" ,
374+ name : "LocalAppData specified" ,
375+ onlyWindows : true ,
374376 env : map [string ]string {
375- "GH_CONFIG_DIR " : filepath . Join ( tempDir , "gh_config_dir" ) ,
377+ "LocalAppData " : tempDir ,
376378 },
377- output : filepath .Join (tempDir , "gh_config_dir" ),
379+ output : filepath .Join (tempDir , "GitHub CLI" ),
380+ },
381+ {
382+ name : "XDG_STATE_HOME and LocalAppData specified" ,
383+ onlyWindows : true ,
384+ env : map [string ]string {
385+ "XDG_STATE_HOME" : tempDir ,
386+ "LocalAppData" : tempDir ,
387+ },
388+ output : filepath .Join (tempDir , "gh" ),
378389 },
379390 }
380391
381392 for _ , tt := range tests {
393+ if tt .onlyWindows && runtime .GOOS != "windows" {
394+ continue
395+ }
382396 t .Run (tt .name , func (t * testing.T ) {
383397 if tt .env != nil {
384398 for k , v := range tt .env {
@@ -443,7 +457,7 @@ func Test_autoMigrateStateDir_migration(t *testing.T) {
443457 homeDir := t .TempDir ()
444458 migrateDir := t .TempDir ()
445459 homeConfigDir := filepath .Join (homeDir , ".config" , "gh" )
446- migrateConfigDir := filepath .Join (migrateDir , ".config " , "gh" )
460+ migrateStateDir := filepath .Join (migrateDir , ".local" , "state " , "gh" )
447461
448462 homeEnvVar := "HOME"
449463 if runtime .GOOS == "windows" {
@@ -458,14 +472,14 @@ func Test_autoMigrateStateDir_migration(t *testing.T) {
458472 err = ioutil .WriteFile (filepath .Join (homeConfigDir , "state.yml" ), nil , 0755 )
459473 assert .NoError (t , err )
460474
461- err = autoMigrateStateDir (migrateConfigDir )
475+ err = autoMigrateStateDir (migrateStateDir )
462476 assert .NoError (t , err )
463477
464478 files , err := ioutil .ReadDir (homeConfigDir )
465479 assert .NoError (t , err )
466480 assert .Equal (t , 0 , len (files ))
467481
468- files , err = ioutil .ReadDir (migrateConfigDir )
482+ files , err = ioutil .ReadDir (migrateStateDir )
469483 assert .NoError (t , err )
470484 assert .Equal (t , 1 , len (files ))
471485 assert .Equal (t , "state.yml" , files [0 ].Name ())
0 commit comments