@@ -25,55 +25,39 @@ import (
2525	"github.com/stretchr/testify/require" 
2626)
2727
28- func  makeDirStructure (tgt  string ) (string , string , error ) {
28+ func  makeDirStructure (tb  testing.TB , tgt  string ) (string , string ) {
29+ 	tb .Helper ()
30+ 
2931	if  tgt  ==  ""  {
3032		tgt  =  "pkgpaths" 
3133	}
32- 	td , err  :=  os .MkdirTemp ("" , tgt )
33- 	if  err  !=  nil  {
34- 		return  "" , "" , err 
35- 	}
36- 	td2 , err  :=  os .MkdirTemp ("" , tgt + "-2" )
37- 	if  err  !=  nil  {
38- 		return  "" , "" , err 
39- 	}
34+ 
35+ 	td  :=  tb .TempDir ()
4036	realPath  :=  filepath .Join (td , "src" , "foo" , "bar" )
41- 	if  err  :=  os .MkdirAll (realPath , os .ModePerm ); err  !=  nil  {
42- 		return  "" , "" , err 
43- 	}
37+ 	err  :=  os .MkdirAll (realPath , os .ModePerm )
38+ 	require .NoError (tb , err )
4439	linkPathBase  :=  filepath .Join (td , "src" , "baz" )
45- 	if  err  :=  os .MkdirAll (linkPathBase , os .ModePerm ); err  !=  nil  {
46- 		return  "" , "" , err 
47- 	}
40+ 	err  =  os .MkdirAll (linkPathBase , os .ModePerm )
41+ 	require .NoError (tb , err )
4842	linkPath  :=  filepath .Join (linkPathBase , "das" )
49- 	if  err  :=  os .Symlink (realPath , linkPath ); err  !=  nil  {
50- 		return  "" , "" , err 
51- 	}
43+ 	err  =  os .Symlink (realPath , linkPath )
44+ 	require .NoError (tb , err )
5245
46+ 	td2  :=  tb .TempDir ()
5347	realPath  =  filepath .Join (td2 , "src" , "fuu" , "bir" )
54- 	if  err  :=  os .MkdirAll (realPath , os .ModePerm ); err  !=  nil  {
55- 		return  "" , "" , err 
56- 	}
48+ 	err  =  os .MkdirAll (realPath , os .ModePerm )
49+ 	require .NoError (tb , err )
5750	linkPathBase  =  filepath .Join (td2 , "src" , "biz" )
58- 	if  err  :=  os .MkdirAll (linkPathBase , os .ModePerm ); err  !=  nil  {
59- 		return  "" , "" , err 
60- 	}
51+ 	err  =  os .MkdirAll (linkPathBase , os .ModePerm )
52+ 	require .NoError (tb , err )
6153	linkPath  =  filepath .Join (linkPathBase , "dis" )
62- 	if  err  :=  os .Symlink (realPath , linkPath ); err  !=  nil  {
63- 		return  "" , "" , err 
64- 	}
65- 	return  td , td2 , nil 
54+ 	err  =  os .Symlink (realPath , linkPath )
55+ 	require .NoError (tb , err )
56+ 	return  td , td2 
6657}
6758
6859func  TestFindPackage (t  * testing.T ) {
69- 	pth , pth2 , err  :=  makeDirStructure ("" )
70- 	if  err  !=  nil  {
71- 		t .Fatal (err )
72- 	}
73- 	defer  func () {
74- 		os .RemoveAll (pth )
75- 		os .RemoveAll (pth2 )
76- 	}()
60+ 	pth , pth2  :=  makeDirStructure (t , "" )
7761
7862	searchPath  :=  pth  +  string (filepath .ListSeparator ) +  pth2 
7963	// finds package when real name mentioned 
0 commit comments