File: mount_linux_test.go

package info (click to toggle)
golang-github-jacobsa-fuse 0.0~git20250829.cbc61fa-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 812 kB
  • sloc: makefile: 4
file content (37 lines) | stat: -rw-r--r-- 721 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package fuse

import (
	"testing"
)

func Test_parseFuseFd(t *testing.T) {
	t.Run("valid", func(t *testing.T) {
		fd, err := parseFuseFd("/dev/fd/42")
		if fd != 42 {
			t.Errorf("expected 42, got %d", fd)
		}
		if err != nil {
			t.Errorf("expected no error, got %#v", err)
		}
	})

	t.Run("negative", func(t *testing.T) {
		fd, err := parseFuseFd("/dev/fd/-42")
		if fd != -1 {
			t.Errorf("expected an invalid fd, got %d", fd)
		}
		if err == nil {
			t.Errorf("expected an error, nil")
		}
	})

	t.Run("not an int", func(t *testing.T) {
		fd, err := parseFuseFd("/dev/fd/3.14159")
		if fd != -1 {
			t.Errorf("expected an invalid fd, got %d", fd)
		}
		if err == nil {
			t.Errorf("expected an error, nil")
		}
	})
}