Skip to content

Commit c38a0f5

Browse files
committed
refactor cli
1 parent 9a3731d commit c38a0f5

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

cli/logout_test.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,18 @@ func TestLogout(t *testing.T) {
146146
err = os.Chmod(string(config), 0500)
147147
require.NoError(t, err)
148148
}
149+
t.Cleanup(func() {
150+
// Setting the permissions back for cleanup.
151+
if runtime.GOOS == "windows" {
152+
err = os.Chmod(string(config.URL()), 0600)
153+
require.NoError(t, err)
154+
err = os.Chmod(string(config.Session()), 0600)
155+
require.NoError(t, err)
156+
} else {
157+
err = os.Chmod(string(config), 0700)
158+
require.NoError(t, err)
159+
}
160+
})
149161

150162
logoutChan := make(chan struct{})
151163
logout, _ := clitest.New(t, "logout", "--global-config", string(config))
@@ -164,19 +176,6 @@ func TestLogout(t *testing.T) {
164176
pty.ExpectMatch("Are you sure you want to logout?")
165177
pty.WriteLine("yes")
166178
<-logoutChan
167-
168-
t.Cleanup(func() {
169-
// Setting the permissions back for cleanup.
170-
if runtime.GOOS == "windows" {
171-
err = os.Chmod(string(config.URL()), 0600)
172-
require.NoError(t, err)
173-
err = os.Chmod(string(config.Session()), 0600)
174-
require.NoError(t, err)
175-
} else {
176-
err = os.Chmod(string(config), 0700)
177-
require.NoError(t, err)
178-
}
179-
})
180179
})
181180
}
182181

0 commit comments

Comments
 (0)