@@ -16,24 +16,33 @@ suite("Authenticate", () => {
1616
1717 teardown ( ( ) => utils . resetEnv ( ) )
1818
19+ const assertDir = ( actual : string , expected : string ) => {
20+ assert . match ( actual , new RegExp ( expected . replace ( / \\ / g, "\\$&" ) + "$" ) )
21+ }
22+
1923 const assertDirs = ( dir : string ) => {
20- assert . match ( auth . getConfigDir ( "linux" ) , new RegExp ( path . join ( dir , ".config$" ) ) )
21- assert . match ( auth . getConfigDir ( "freebsd" ) , new RegExp ( path . join ( dir , ".config$" ) ) )
22- assert . match ( auth . getConfigDir ( "win32" ) , new RegExp ( path . join ( dir , "AppData/Roaming$" ) ) )
23- assert . match ( auth . getConfigDir ( "darwin" ) , new RegExp ( path . join ( dir , "Library/Application Support$" ) ) )
24+ assertDir ( auth . getConfigDir ( "linux" ) , path . join ( dir , ".config" ) )
25+ assertDir ( auth . getConfigDir ( "freebsd" ) , path . join ( dir , ".config" ) )
26+ assertDir ( auth . getConfigDir ( "win32" ) , path . join ( dir , "AppData/Roaming" ) )
27+ assertDir ( auth . getConfigDir ( "darwin" ) , path . join ( dir , "Library/Application Support" ) )
2428 }
2529
2630 test ( "getConfigDir" , async ( ) => {
2731 // Make sure local config mocks work.
2832 const tmpDir = await utils . tmpdir ( tmpPath )
2933 utils . setEnv ( "HOME" , tmpDir )
34+ utils . setEnv ( "USERPROFILE" , tmpDir )
35+ utils . setEnv ( "XDG_CONFIG_HOME" , undefined )
36+ utils . setEnv ( "APPDATA" , undefined )
3037 assertDirs ( tmpDir )
3138
3239 // Make sure the global mock also works. For example the Linux temp config
3340 // directory looks like: /tmp/coder/tests/config/tmp-Dzfqwl/home/.config
3441 // This runs after the local mock to make sure environment variables are
3542 // being restored correctly.
3643 utils . resetEnv ( )
44+ utils . setEnv ( "XDG_CONFIG_HOME" , undefined )
45+ utils . setEnv ( "APPDATA" , undefined )
3746 assertDirs ( "tests/config/.+/home" )
3847 } )
3948
0 commit comments