gopkg.in/dotcloud/docker.v1@v1.13.1/daemon/graphdriver/btrfs/btrfs_test.go (about)

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