github.com/bishtawi/migrate/v4@v4.8.11/source/httpfs/driver_test.go (about)

     1  package httpfs_test
     2  
     3  import (
     4  	"net/http"
     5  	"testing"
     6  
     7  	"github.com/bishtawi/migrate/v4/source/httpfs"
     8  	st "github.com/bishtawi/migrate/v4/source/testing"
     9  )
    10  
    11  func TestNewOK(t *testing.T) {
    12  	d, err := httpfs.New(http.Dir("testdata"), "sql")
    13  	if err != nil {
    14  		t.Errorf("New() expected not error, got: %s", err)
    15  	}
    16  	st.Test(t, d)
    17  }
    18  
    19  func TestNewErrors(t *testing.T) {
    20  	d, err := httpfs.New(http.Dir("does-not-exist"), "")
    21  	if err == nil {
    22  		t.Errorf("New() expected to return error")
    23  	}
    24  	if d != nil {
    25  		t.Errorf("New() expected to return nil driver")
    26  	}
    27  }
    28  
    29  func TestOpen(t *testing.T) {
    30  	d, err := httpfs.New(http.Dir("testdata/sql"), "")
    31  	if err != nil {
    32  		t.Error("New() expected no error")
    33  		return
    34  	}
    35  	d, err = d.Open("")
    36  	if d != nil {
    37  		t.Error("Open() expected to return nil driver")
    38  	}
    39  	if err == nil {
    40  		t.Error("Open() expected to return error")
    41  	}
    42  }