github.com/wulonghui/docker@v1.8.0-rc2/pkg/useragent/useragent_test.go (about)

     1  package useragent
     2  
     3  import "testing"
     4  
     5  func TestVersionInfo(t *testing.T) {
     6  	vi := VersionInfo{"foo", "bar"}
     7  	if !vi.isValid() {
     8  		t.Fatalf("VersionInfo should be valid")
     9  	}
    10  	vi = VersionInfo{"", "bar"}
    11  	if vi.isValid() {
    12  		t.Fatalf("Expected VersionInfo to be invalid")
    13  	}
    14  	vi = VersionInfo{"foo", ""}
    15  	if vi.isValid() {
    16  		t.Fatalf("Expected VersionInfo to be invalid")
    17  	}
    18  }
    19  
    20  func TestAppendVersions(t *testing.T) {
    21  	vis := []VersionInfo{
    22  		{"foo", "1.0"},
    23  		{"bar", "0.1"},
    24  		{"pi", "3.1.4"},
    25  	}
    26  	v := AppendVersions("base", vis...)
    27  	expect := "base foo/1.0 bar/0.1 pi/3.1.4"
    28  	if v != expect {
    29  		t.Fatalf("expected %q, got %q", expect, v)
    30  	}
    31  }