dispatchers_windows_test.go 919 B

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