Source file src/cmd/go/internal/modfetch/cache_readonly_test.go

     1  // Copyright 2025 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build !plan9 && !windows
     6  
     7  package modfetch
     8  
     9  import (
    10  	"fmt"
    11  	"syscall"
    12  	"testing"
    13  )
    14  
    15  func TestIsErrReadOnlyFS(t *testing.T) {
    16  	if isErrReadOnlyFS(nil) {
    17  		t.Error("isErrReadOnlyFS(nil) = true, want false")
    18  	}
    19  	if isErrReadOnlyFS(fmt.Errorf("some error")) {
    20  		t.Error("isErrReadOnlyFS(non-EROFS) = true, want false")
    21  	}
    22  	if !isErrReadOnlyFS(syscall.EROFS) {
    23  		t.Error("isErrReadOnlyFS(syscall.EROFS) = false, want true")
    24  	}
    25  	if !isErrReadOnlyFS(fmt.Errorf("wrapped: %w", syscall.EROFS)) {
    26  		t.Error("isErrReadOnlyFS(wrapped EROFS) = false, want true")
    27  	}
    28  	if isErrReadOnlyFS(syscall.EACCES) {
    29  		t.Error("isErrReadOnlyFS(syscall.EACCES) = true, want false")
    30  	}
    31  }
    32  

View as plain text