| 1 | package tgz_testscip-go gomod github.com/go-git/go-git-fixtures/v6 . `github.com/go-git/go-git-fixtures/v6/internal/tgz_test`/ |
| 2 | |
| 3 | import ( |
| 4 | "fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/" |
| 5 | "osscip-go gomod github.com/golang/go/src go1.25.0 os/" |
| 6 | "path/filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/" |
| 7 | "testingscip-go gomod github.com/golang/go/src go1.25.0 testing/" |
| 8 | |
| 9 | "github.com/go-git/go-billy/v6scip-go gomod github.com/go-git/go-billy/v6 v6.0.0-alpha.1 `github.com/go-git/go-billy/v6`/" |
| 10 | "github.com/go-git/go-billy/v6/osfsscip-go gomod github.com/go-git/go-billy/v6 v6.0.0-alpha.1 `github.com/go-git/go-billy/v6/osfs`/" |
| 11 | "github.com/go-git/go-git-fixtures/v6/internal/tgzscip-go gomod github.com/go-git/go-git-fixtures/v6 . `github.com/go-git/go-git-fixtures/v6/internal/tgz`/" |
| 12 | "github.com/stretchr/testify/requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/" |
| 13 | ) |
| 14 | |
| 15 | func TestExtractErrorscip-go gomod github.com/go-git/go-git-fixtures/v6 . `github.com/go-git/go-git-fixtures/v6/internal/tgz_test`/TestExtractError().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 16 | t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().() |
| 17 | |
| 18 | tests := []struct { |
| 19 | tgz string |
| 20 | notFound bool |
| 21 | wantErr string |
| 22 | }{ |
| 23 | { |
| 24 | tgz: "not-found", |
| 25 | notFound: true, |
| 26 | wantErr: "", |
| 27 | }, |
| 28 | { |
| 29 | tgz: "invalid-gzip.tgz", |
| 30 | notFound: false, |
| 31 | wantErr: "gzip: invalid header", |
| 32 | }, |
| 33 | { |
| 34 | tgz: "not-a-tar.tgz", |
| 35 | notFound: false, |
| 36 | wantErr: "unexpected EOF", |
| 37 | }, |
| 38 | } |
| 39 | |
| 40 | for _, tc := range tests { |
| 41 | t.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Run().("tgz path = "+tc.tgz, func(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 42 | t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().() |
| 43 | |
| 44 | d, err := osscip-go gomod github.com/golang/go/src go1.25.0 os/.Getwdscip-go gomod github.com/golang/go/src go1.25.0 os/Getwd().() |
| 45 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 46 | |
| 47 | source := osfsscip-go gomod github.com/go-git/go-billy/v6 v6.0.0-alpha.1 `github.com/go-git/go-billy/v6/osfs`/.Newscip-go gomod github.com/go-git/go-billy/v6 v6.0.0-alpha.1 `github.com/go-git/go-billy/v6/osfs`/New().(d + "/fixtures") |
| 48 | |
| 49 | f, err := source.Openscip-go gomod github.com/go-git/go-billy/v6 v6.0.0-alpha.1 `github.com/go-git/go-billy/v6`/Basic#Open().(tc.tgz) |
| 50 | if tc.notFound { |
| 51 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.ErrorIsscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/ErrorIs().(t, err, osscip-go gomod github.com/golang/go/src go1.25.0 os/.ErrNotExistscip-go gomod github.com/golang/go/src go1.25.0 os/ErrNotExist.) |
| 52 | } else { |
| 53 | fs, err := tgzscip-go gomod github.com/go-git/go-git-fixtures/v6 . `github.com/go-git/go-git-fixtures/v6/internal/tgz`/.MemFactoryscip-go gomod github.com/go-git/go-git-fixtures/v6 . `github.com/go-git/go-git-fixtures/v6/internal/tgz`/MemFactory.() |
| 54 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 55 | |
| 56 | err = tgzscip-go gomod github.com/go-git/go-git-fixtures/v6 . `github.com/go-git/go-git-fixtures/v6/internal/tgz`/.Extractscip-go gomod github.com/go-git/go-git-fixtures/v6 . `github.com/go-git/go-git-fixtures/v6/internal/tgz`/Extract().(f, fs) |
| 57 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.ErrorContainsscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/ErrorContains().(t, err, tc.wantErr) |
| 58 | } |
| 59 | }) |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | func TestExtractscip-go gomod github.com/go-git/go-git-fixtures/v6 . `github.com/go-git/go-git-fixtures/v6/internal/tgz_test`/TestExtract().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { //nolint |
| 64 | t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().() |
| 65 | |
| 66 | tests := []struct { |
| 67 | tgz string |
| 68 | tree []string |
| 69 | }{ |
| 70 | { |
| 71 | tgz: "test-01.tgz", |
| 72 | tree: []string{ |
| 73 | "foo.txt", |
| 74 | }, |
| 75 | }, { |
| 76 | tgz: "test-02.tgz", |
| 77 | tree: []string{ |
| 78 | "baz.txt", |
| 79 | "bla.txt", |
| 80 | "foo.txt", |
| 81 | }, |
| 82 | }, { |
| 83 | tgz: "test-03.tgz", |
| 84 | tree: []string{ |
| 85 | "bar", |
| 86 | filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Join().("bar", "baz.txt"), |
| 87 | filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Join().("bar", "foo.txt"), |
| 88 | "baz", |
| 89 | filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Join().("baz", "bar"), |
| 90 | filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Join().("baz", "bar", "foo.txt"), |
| 91 | filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Join().("baz", "baz"), |
| 92 | filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Join().("baz", "baz", "baz"), |
| 93 | filepathscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.25.0 `path/filepath`/Join().("baz", "baz", "baz", "foo.txt"), |
| 94 | "foo.txt", |
| 95 | }, |
| 96 | }, |
| 97 | } |
| 98 | |
| 99 | factories := []struct { |
| 100 | name string |
| 101 | factory func() (billyscip-go gomod github.com/go-git/go-billy/v6 v6.0.0-alpha.1 `github.com/go-git/go-billy/v6`/.Filesystemscip-go gomod github.com/go-git/go-billy/v6 v6.0.0-alpha.1 `github.com/go-git/go-billy/v6`/Filesystem#, error) |
| 102 | }{ |
| 103 | {name: "mem", factory: tgzscip-go gomod github.com/go-git/go-git-fixtures/v6 . `github.com/go-git/go-git-fixtures/v6/internal/tgz`/.MemFactoryscip-go gomod github.com/go-git/go-git-fixtures/v6 . `github.com/go-git/go-git-fixtures/v6/internal/tgz`/MemFactory.}, |
| 104 | {name: "osfs-temp", factory: func() (billyscip-go gomod github.com/go-git/go-billy/v6 v6.0.0-alpha.1 `github.com/go-git/go-billy/v6`/.Filesystemscip-go gomod github.com/go-git/go-billy/v6 v6.0.0-alpha.1 `github.com/go-git/go-billy/v6`/Filesystem#, error) { |
| 105 | return osfsscip-go gomod github.com/go-git/go-billy/v6 v6.0.0-alpha.1 `github.com/go-git/go-billy/v6/osfs`/.Newscip-go gomod github.com/go-git/go-billy/v6 v6.0.0-alpha.1 `github.com/go-git/go-billy/v6/osfs`/New().(t.TempDirscip-go gomod github.com/golang/go/src go1.25.0 testing/common#TempDir().(), osfsscip-go gomod github.com/go-git/go-billy/v6 v6.0.0-alpha.1 `github.com/go-git/go-billy/v6/osfs`/.WithBoundOSscip-go gomod github.com/go-git/go-billy/v6 v6.0.0-alpha.1 `github.com/go-git/go-billy/v6/osfs`/WithBoundOS().()), nil |
| 106 | }}, |
| 107 | } |
| 108 | |
| 109 | for _, ff := range factories { |
| 110 | for _, tc := range tests { |
| 111 | t.Runscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Run().(fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().("[%s] tgz path = %s", ff.name, tc.tgz), func(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 112 | t.Parallelscip-go gomod github.com/golang/go/src go1.25.0 testing/T#Parallel().() |
| 113 | |
| 114 | source := osfsscip-go gomod github.com/go-git/go-billy/v6 v6.0.0-alpha.1 `github.com/go-git/go-billy/v6/osfs`/.Newscip-go gomod github.com/go-git/go-billy/v6 v6.0.0-alpha.1 `github.com/go-git/go-billy/v6/osfs`/New().("fixtures", osfsscip-go gomod github.com/go-git/go-billy/v6 v6.0.0-alpha.1 `github.com/go-git/go-billy/v6/osfs`/.WithBoundOSscip-go gomod github.com/go-git/go-billy/v6 v6.0.0-alpha.1 `github.com/go-git/go-billy/v6/osfs`/WithBoundOS().()) |
| 115 | f, err := source.Openscip-go gomod github.com/go-git/go-billy/v6 v6.0.0-alpha.1 `github.com/go-git/go-billy/v6`/Basic#Open().(tc.tgz) |
| 116 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 117 | |
| 118 | fs, err := ff.factory() |
| 119 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 120 | |
| 121 | err = tgzscip-go gomod github.com/go-git/go-git-fixtures/v6 . `github.com/go-git/go-git-fixtures/v6/internal/tgz`/.Extractscip-go gomod github.com/go-git/go-git-fixtures/v6 . `github.com/go-git/go-git-fixtures/v6/internal/tgz`/Extract().(f, fs) |
| 122 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err, "%s: unexpected error extracting: %s", tc.tgz, err) |
| 123 | |
| 124 | for _, path := range tc.tree { |
| 125 | _, err = fs.Statscip-go gomod github.com/go-git/go-billy/v6 v6.0.0-alpha.1 `github.com/go-git/go-billy/v6`/Basic#Stat().(path) |
| 126 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 127 | } |
| 128 | }) |
| 129 | } |
| 130 | } |
| 131 | } |