github.com/csfrancis/docker@v1.8.0-rc2/builder/support_test.go (about)

     1  package builder
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  )
     7  
     8  func TestSelectAcceptableMIME(t *testing.T) {
     9  	validMimeStrings := []string{
    10  		"application/x-bzip2",
    11  		"application/bzip2",
    12  		"application/gzip",
    13  		"application/x-gzip",
    14  		"application/x-xz",
    15  		"application/xz",
    16  		"application/tar",
    17  		"application/x-tar",
    18  		"application/octet-stream",
    19  		"text/plain",
    20  	}
    21  
    22  	invalidMimeStrings := []string{
    23  		"",
    24  		"application/octet",
    25  		"application/json",
    26  	}
    27  
    28  	for _, m := range invalidMimeStrings {
    29  		if len(selectAcceptableMIME(m)) > 0 {
    30  			err := fmt.Errorf("Should not have accepted %q", m)
    31  			t.Fatal(err)
    32  		}
    33  	}
    34  
    35  	for _, m := range validMimeStrings {
    36  		if str := selectAcceptableMIME(m); str == "" {
    37  			err := fmt.Errorf("Should have accepted %q", m)
    38  			t.Fatal(err)
    39  		}
    40  	}
    41  }