github.com/Heebron/moby@v0.0.0-20221111184709-6eab4f55faf7/daemon/graphdriver/btrfs/btrfs_test.go (about)

     1  //go:build linux
     2  // +build linux
     3  
     4  package btrfs // import "github.com/docker/docker/daemon/graphdriver/btrfs"
     5  
     6  import (
     7  	"os"
     8  	"path"
     9  	"testing"
    10  
    11  	"github.com/docker/docker/daemon/graphdriver/graphtest"
    12  )
    13  
    14  // This avoids creating a new driver for each test if all tests are run
    15  // Make sure to put new tests between TestBtrfsSetup and TestBtrfsTeardown
    16  func TestBtrfsSetup(t *testing.T) {
    17  	graphtest.GetDriver(t, "btrfs")
    18  }
    19  
    20  func TestBtrfsCreateEmpty(t *testing.T) {
    21  	graphtest.DriverTestCreateEmpty(t, "btrfs")
    22  }
    23  
    24  func TestBtrfsCreateBase(t *testing.T) {
    25  	graphtest.DriverTestCreateBase(t, "btrfs")
    26  }
    27  
    28  func TestBtrfsCreateSnap(t *testing.T) {
    29  	graphtest.DriverTestCreateSnap(t, "btrfs")
    30  }
    31  
    32  func TestBtrfsSubvolDelete(t *testing.T) {
    33  	d := graphtest.GetDriver(t, "btrfs")
    34  	if err := d.CreateReadWrite("test", "", nil); err != nil {
    35  		t.Fatal(err)
    36  	}
    37  	defer graphtest.PutDriver(t)
    38  
    39  	dir, err := d.Get("test", "")
    40  	if err != nil {
    41  		t.Fatal(err)
    42  	}
    43  	defer d.Put("test")
    44  
    45  	if err := subvolCreate(dir, "subvoltest"); err != nil {
    46  		t.Fatal(err)
    47  	}
    48  
    49  	if _, err := os.Stat(path.Join(dir, "subvoltest")); err != nil {
    50  		t.Fatal(err)
    51  	}
    52  
    53  	if err := d.Remove("test"); err != nil {
    54  		t.Fatal(err)
    55  	}
    56  
    57  	if _, err := os.Stat(path.Join(dir, "subvoltest")); !os.IsNotExist(err) {
    58  		t.Fatalf("expected not exist error on nested subvol, got: %v", err)
    59  	}
    60  }
    61  
    62  func TestBtrfsTeardown(t *testing.T) {
    63  	graphtest.PutDriver(t)
    64  }