github.com/vieux/docker@v0.6.3-0.20161004191708-e097c2a938c7/builder/dockerfile/dispatchers_windows_test.go (about)

     1  // +build windows
     2  
     3  package dockerfile
     4  
     5  import "testing"
     6  
     7  func TestNormaliseWorkdir(t *testing.T) {
     8  	tests := []struct{ current, requested, expected, etext string }{
     9  		{``, ``, ``, `cannot normalise nothing`},
    10  		{``, `a`, `C:\a`, ``},
    11  		{``, `c:\foo`, `C:\foo`, ``},
    12  		{``, `\foo`, `C:\foo`, ``},
    13  		{``, `/foo`, `C:\foo`, ``},
    14  		{``, `C:/foo`, `C:\foo`, ``},
    15  		{`C:\foo`, `bar`, `C:\foo\bar`, ``},
    16  		{`C:\foo`, `/bar`, `C:\bar`, ``},
    17  		{`C:\foo`, `\bar`, `C:\bar`, ``},
    18  	}
    19  	for _, i := range tests {
    20  		r, e := normaliseWorkdir(i.current, i.requested)
    21  
    22  		if i.etext != "" && e == nil {
    23  			t.Fatalf("TestNormaliseWorkingDir Expected error %s", i.etext)
    24  		}
    25  
    26  		if i.etext != "" && e.Error() != i.etext {
    27  			t.Fatalf("TestNormaliseWorkingDir Expected error %s, got %s", i.etext, e.Error())
    28  		}
    29  
    30  		if r != i.expected {
    31  			t.Fatalf("TestNormaliseWorkingDir Expected %s for %s %s", i.expected, i.current, i.requested)
    32  		}
    33  	}
    34  }