Source file src/os/error_unix_test.go

     1  // Copyright 2016 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 unix || (js && wasm) || wasip1
     6  
     7  package os_test
     8  
     9  import (
    10  	"io/fs"
    11  	"os"
    12  	"syscall"
    13  )
    14  
    15  func init() {
    16  	isExistTests = append(isExistTests,
    17  		isExistTest{err: &fs.PathError{Err: syscall.EEXIST}, is: true, isnot: false},
    18  		isExistTest{err: &fs.PathError{Err: syscall.ENOTEMPTY}, is: true, isnot: false},
    19  
    20  		isExistTest{err: &os.LinkError{Err: syscall.EEXIST}, is: true, isnot: false},
    21  		isExistTest{err: &os.LinkError{Err: syscall.ENOTEMPTY}, is: true, isnot: false},
    22  
    23  		isExistTest{err: &os.SyscallError{Err: syscall.EEXIST}, is: true, isnot: false},
    24  		isExistTest{err: &os.SyscallError{Err: syscall.ENOTEMPTY}, is: true, isnot: false},
    25  	)
    26  	isPermissionTests = append(isPermissionTests,
    27  		isPermissionTest{err: &fs.PathError{Err: syscall.EACCES}, want: true},
    28  		isPermissionTest{err: &fs.PathError{Err: syscall.EPERM}, want: true},
    29  		isPermissionTest{err: &fs.PathError{Err: syscall.EEXIST}, want: false},
    30  
    31  		isPermissionTest{err: &os.LinkError{Err: syscall.EACCES}, want: true},
    32  		isPermissionTest{err: &os.LinkError{Err: syscall.EPERM}, want: true},
    33  		isPermissionTest{err: &os.LinkError{Err: syscall.EEXIST}, want: false},
    34  
    35  		isPermissionTest{err: &os.SyscallError{Err: syscall.EACCES}, want: true},
    36  		isPermissionTest{err: &os.SyscallError{Err: syscall.EPERM}, want: true},
    37  		isPermissionTest{err: &os.SyscallError{Err: syscall.EEXIST}, want: false},
    38  	)
    39  
    40  }
    41  

View as plain text