github.com/seashell-org/golang-migrate/v4@v4.15.3-0.20220722221203-6ab6c6c062d1/util_test.go (about)

     1  package migrate
     2  
     3  import (
     4  	nurl "net/url"
     5  	"testing"
     6  )
     7  
     8  func TestSuintPanicsWithNegativeInput(t *testing.T) {
     9  	defer func() {
    10  		if r := recover(); r == nil {
    11  			t.Fatal("expected suint to panic for -1")
    12  		}
    13  	}()
    14  	suint(-1)
    15  }
    16  
    17  func TestSuint(t *testing.T) {
    18  	if u := suint(0); u != 0 {
    19  		t.Fatalf("expected 0, got %v", u)
    20  	}
    21  }
    22  
    23  func TestFilterCustomQuery(t *testing.T) {
    24  	n, err := nurl.Parse("foo://host?a=b&x-custom=foo&c=d&ok=y")
    25  	if err != nil {
    26  		t.Fatal(err)
    27  	}
    28  	nx := FilterCustomQuery(n).Query()
    29  	if nx.Get("x-custom") != "" {
    30  		t.Fatalf("didn't expect x-custom")
    31  	}
    32  	if nx.Get("ok") != "y" {
    33  		t.Fatalf("expected ok=y, got %v", nx.Get("ok"))
    34  	}
    35  }