File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -67,10 +67,7 @@ func TestWriteBinaryResponse(t *testing.T) {
6767
6868func TestCreateDownloadFile (t * testing.T ) {
6969 t .Run ("creates file with filename from header" , func (t * testing.T ) {
70- tmpDir := t .TempDir ()
71- oldWd , _ := os .Getwd ()
72- os .Chdir (tmpDir )
73- defer os .Chdir (oldWd )
70+ t .Chdir (t .TempDir ())
7471
7572 resp := & http.Response {
7673 Header : http.Header {
@@ -96,10 +93,7 @@ func TestCreateDownloadFile(t *testing.T) {
9693 })
9794
9895 t .Run ("creates temp file when no header" , func (t * testing.T ) {
99- tmpDir := t .TempDir ()
100- oldWd , _ := os .Getwd ()
101- os .Chdir (tmpDir )
102- defer os .Chdir (oldWd )
96+ t .Chdir (t .TempDir ())
10397
10498 resp := & http.Response {Header : http.Header {}}
10599 file , err := createDownloadFile (resp , []byte ("test content" ))
@@ -109,10 +103,7 @@ func TestCreateDownloadFile(t *testing.T) {
109103 })
110104
111105 t .Run ("prevents directory traversal" , func (t * testing.T ) {
112- tmpDir := t .TempDir ()
113- oldWd , _ := os .Getwd ()
114- os .Chdir (tmpDir )
115- defer os .Chdir (oldWd )
106+ t .Chdir (t .TempDir ())
116107
117108 resp := & http.Response {
118109 Header : http.Header {
You can’t perform that action at this time.
0 commit comments