github.com/bananabytelabs/wazero@v0.0.0-20240105073314-54b22a776da8/internal/gojs/custom/fs_test.go (about)

     1  package custom
     2  
     3  import (
     4  	"io/fs"
     5  	"os"
     6  	"testing"
     7  
     8  	"github.com/bananabytelabs/wazero/internal/testing/require"
     9  )
    10  
    11  func Test_ToJsMode(t *testing.T) {
    12  	t.Run("/dev/null", func(t *testing.T) {
    13  		st, err := os.Stat(os.DevNull)
    14  		require.NoError(t, err)
    15  
    16  		fm := ToJsMode(st.Mode())
    17  
    18  		// Should be a character device, and retain the permissions.
    19  		require.Equal(t, S_IFCHR|uint32(st.Mode().Perm()), fm)
    20  	})
    21  }
    22  
    23  func Test_FromJsMode(t *testing.T) {
    24  	t.Run("sticky bit", func(t *testing.T) {
    25  		jsMode := ToJsMode(0o0755 | fs.ModeSticky)
    26  		require.Equal(t, 0o0755|S_IFREG|S_ISVTX, jsMode)
    27  	})
    28  }