@cryptotaxi247 / kubo / commits / 36de939e2

test: repo migrations fetch - skip part of a test on windows since it does not support read-only directories

Adin Schmahmann committed Mar 25, 2021 at 15:55 UTC 36de939e25fce2dd19118206b9f857de9bc76e98
1 file changed +25 -19
repo/fsrepo/migrations/fetch_test.go
+25 -19
@@ -10,6 +10,7 @@ import (
10 "net/http/httptest"
11 "os"
12 "path"
13 + "runtime"
14 "strings"
15 "testing"
16 )
@@ -183,25 +184,30 @@ func TestFetchBinary(t *testing.T) {
184 os.Remove(path.Join(tmpDir, ExeName("ipfs")))
185
186 // Check error creating temp download directory
186 - err = os.Chmod(tmpDir, 0555)
187 - if err != nil {
188 - panic(err)
189 - }
190 - err = os.Setenv("TMPDIR", tmpDir)
191 - if err != nil {
192 - panic(err)
193 - }
194 - _, err = FetchBinary(ctx, fetcher, "go-ipfs", "v0.3.5", "ipfs", tmpDir)
195 - if !os.IsPermission(err) {
196 - t.Error("expected 'permission' error, got:", err)
197 - }
198 - err = os.Setenv("TMPDIR", "/tmp")
199 - if err != nil {
200 - panic(err)
201 - }
202 - err = os.Chmod(tmpDir, 0755)
203 - if err != nil {
204 - panic(err)
187 + //
188 + // Windows doesn't have read-only directories https://github.com/golang/go/issues/35042 this would need to be
189 + // tested another way
190 + if runtime.GOOS != "windows" {
191 + err = os.Chmod(tmpDir, 0555)
192 + if err != nil {
193 + panic(err)
194 + }
195 + err = os.Setenv("TMPDIR", tmpDir)
196 + if err != nil {
197 + panic(err)
198 + }
199 + _, err = FetchBinary(ctx, fetcher, "go-ipfs", "v0.3.5", "ipfs", tmpDir)
200 + if !os.IsPermission(err) {
201 + t.Error("expected 'permission' error, got:", err)
202 + }
203 + err = os.Setenv("TMPDIR", "/tmp")
204 + if err != nil {
205 + panic(err)
206 + }
207 + err = os.Chmod(tmpDir, 0755)
208 + if err != nil {
209 + panic(err)
210 + }
211 }
212
213 // Check error if failure to fetch due to bad dist