@@ -818,37 +818,29 @@ var codeRepoVersionsTests = []struct {
818
818
func TestCodeRepoVersions (t * testing.T ) {
819
819
testenv .MustHaveExternalNetwork (t )
820
820
821
- tmpdir , err := os .MkdirTemp ("" , "vgo-modfetch-test-" )
822
- if err != nil {
823
- t .Fatal (err )
824
- }
825
- defer os .RemoveAll (tmpdir )
826
-
827
- t .Run ("parallel" , func (t * testing.T ) {
828
- for _ , tt := range codeRepoVersionsTests {
829
- tt := tt
830
- t .Run (strings .ReplaceAll (tt .path , "/" , "_" ), func (t * testing.T ) {
831
- if strings .Contains (tt .path , "gopkg.in" ) {
832
- testenv .SkipFlaky (t , 54503 )
833
- }
821
+ for _ , tt := range codeRepoVersionsTests {
822
+ tt := tt
823
+ t .Run (strings .ReplaceAll (tt .path , "/" , "_" ), func (t * testing.T ) {
824
+ if strings .Contains (tt .path , "gopkg.in" ) {
825
+ testenv .SkipFlaky (t , 54503 )
826
+ }
834
827
835
- t .Parallel ()
836
- if tt .vcs != "mod" {
837
- testenv .MustHaveExecPath (t , tt .vcs )
838
- }
839
- ctx := context .Background ()
828
+ t .Parallel ()
829
+ if tt .vcs != "mod" {
830
+ testenv .MustHaveExecPath (t , tt .vcs )
831
+ }
832
+ ctx := context .Background ()
840
833
841
- repo := Lookup (ctx , "direct" , tt .path )
842
- list , err := repo .Versions (ctx , tt .prefix )
843
- if err != nil {
844
- t .Fatalf ("Versions(%q): %v" , tt .prefix , err )
845
- }
846
- if ! reflect .DeepEqual (list .List , tt .versions ) {
847
- t .Fatalf ("Versions(%q):\n have %v\n want %v" , tt .prefix , list , tt .versions )
848
- }
849
- })
850
- }
851
- })
834
+ repo := Lookup (ctx , "direct" , tt .path )
835
+ list , err := repo .Versions (ctx , tt .prefix )
836
+ if err != nil {
837
+ t .Fatalf ("Versions(%q): %v" , tt .prefix , err )
838
+ }
839
+ if ! reflect .DeepEqual (list .List , tt .versions ) {
840
+ t .Fatalf ("Versions(%q):\n have %v\n want %v" , tt .prefix , list , tt .versions )
841
+ }
842
+ })
843
+ }
852
844
}
853
845
854
846
var latestTests = []struct {
@@ -897,43 +889,35 @@ var latestTests = []struct {
897
889
func TestLatest (t * testing.T ) {
898
890
testenv .MustHaveExternalNetwork (t )
899
891
900
- tmpdir , err := os .MkdirTemp ("" , "vgo-modfetch-test-" )
901
- if err != nil {
902
- t .Fatal (err )
903
- }
904
- defer os .RemoveAll (tmpdir )
905
-
906
- t .Run ("parallel" , func (t * testing.T ) {
907
- for _ , tt := range latestTests {
908
- name := strings .ReplaceAll (tt .path , "/" , "_" )
909
- t .Run (name , func (t * testing.T ) {
910
- tt := tt
911
- t .Parallel ()
912
- if tt .vcs != "mod" {
913
- testenv .MustHaveExecPath (t , tt .vcs )
914
- }
915
- ctx := context .Background ()
892
+ for _ , tt := range latestTests {
893
+ name := strings .ReplaceAll (tt .path , "/" , "_" )
894
+ t .Run (name , func (t * testing.T ) {
895
+ tt := tt
896
+ t .Parallel ()
897
+ if tt .vcs != "mod" {
898
+ testenv .MustHaveExecPath (t , tt .vcs )
899
+ }
900
+ ctx := context .Background ()
916
901
917
- repo := Lookup (ctx , "direct" , tt .path )
918
- info , err := repo .Latest (ctx )
919
- if err != nil {
920
- if tt .err != "" {
921
- if err .Error () == tt .err {
922
- return
923
- }
924
- t .Fatalf ("Latest(): %v, want %q" , err , tt .err )
925
- }
926
- t .Fatalf ("Latest(): %v" , err )
927
- }
902
+ repo := Lookup (ctx , "direct" , tt .path )
903
+ info , err := repo .Latest (ctx )
904
+ if err != nil {
928
905
if tt .err != "" {
929
- t . Fatalf ( "Latest( ) = %v, want error %q" , info . Version , tt .err )
930
- }
931
- if info . Version != tt . version {
932
- t .Fatalf ("Latest() = %v, want %v " , info . Version , tt .version )
906
+ if err . Error ( ) == tt .err {
907
+ return
908
+ }
909
+ t .Fatalf ("Latest(): %v, want %q " , err , tt .err )
933
910
}
934
- })
935
- }
936
- })
911
+ t .Fatalf ("Latest(): %v" , err )
912
+ }
913
+ if tt .err != "" {
914
+ t .Fatalf ("Latest() = %v, want error %q" , info .Version , tt .err )
915
+ }
916
+ if info .Version != tt .version {
917
+ t .Fatalf ("Latest() = %v, want %v" , info .Version , tt .version )
918
+ }
919
+ })
920
+ }
937
921
}
938
922
939
923
// fixedTagsRepo is a fake codehost.Repo that returns a fixed list of tags
0 commit comments