hacks for tests on windows

This commit is contained in:
Stephen Roylance 2018-03-19 16:34:36 -04:00
parent 57fb68858b
commit 70815ebaf9
4 changed files with 8 additions and 4 deletions

View File

@ -131,7 +131,7 @@ func RunCreate(f *util.Factory, out io.Writer, c *CreateOptions) error {
} }
// TODO: this does not support a JSON array // TODO: this does not support a JSON array
sections := bytes.Split(contents, []byte("\n---\n")) sections := bytes.Split(bytes.Replace(contents, []byte("\r\n"), []byte("\n"), -1), []byte("\n---\n"))
for _, section := range sections { for _, section := range sections {
defaults := &schema.GroupVersionKind{ defaults := &schema.GroupVersionKind{
Group: v1alpha1.SchemeGroupVersion.Group, Group: v1alpha1.SchemeGroupVersion.Group,

View File

@ -243,7 +243,8 @@ func runCreateClusterIntegrationTest(t *testing.T, srcDir string, version string
t.Fatalf("unexpected error reading expected YAML: %v", err) t.Fatalf("unexpected error reading expected YAML: %v", err)
} }
expectedYAML := strings.TrimSpace(string(expectedYAMLBytes)) //on windows, with git set to autocrlf, the reference files on disk have windows line endings
expectedYAML := strings.Replace(strings.TrimSpace(string(expectedYAMLBytes)), "\r\n", "\n", -1)
actualYAML := strings.Join(yamlAll, "\n\n---\n\n") actualYAML := strings.Join(yamlAll, "\n\n---\n\n")
if actualYAML != expectedYAML { if actualYAML != expectedYAML {

View File

@ -251,6 +251,7 @@ func runTest(t *testing.T, h *testutils.IntegrationTestHarness, clusterName stri
if err != nil { if err != nil {
t.Fatalf("unexpected error reading expected terraform output: %v", err) t.Fatalf("unexpected error reading expected terraform output: %v", err)
} }
testDataTF = bytes.Replace(testDataTF, []byte("\r\n"), []byte("\n"), -1)
if !bytes.Equal(actualTF, testDataTF) { if !bytes.Equal(actualTF, testDataTF) {
diffString := diff.FormatDiff(string(testDataTF), string(actualTF)) diffString := diff.FormatDiff(string(testDataTF), string(actualTF))
@ -543,7 +544,7 @@ func runTestCloudformation(t *testing.T, clusterName string, srcDir string, vers
} }
actualCF = buf.Bytes() actualCF = buf.Bytes()
expectedCFTrimmed := strings.TrimSpace(string(expectedCF)) expectedCFTrimmed := strings.Replace(strings.TrimSpace(string(expectedCF)), "\r\n", "\n", -1)
actualCFTrimmed := strings.TrimSpace(string(actualCF)) actualCFTrimmed := strings.TrimSpace(string(actualCF))
if actualCFTrimmed != expectedCFTrimmed { if actualCFTrimmed != expectedCFTrimmed {
diffString := diff.FormatDiff(expectedCFTrimmed, actualCFTrimmed) diffString := diff.FormatDiff(expectedCFTrimmed, actualCFTrimmed)

View File

@ -68,7 +68,9 @@ func NewIntegrationTestHarness(t *testing.T) *IntegrationTestHarness {
} }
channelPath += "/" channelPath += "/"
h.originalDefaultChannelBase = kops.DefaultChannelBase h.originalDefaultChannelBase = kops.DefaultChannelBase
kops.DefaultChannelBase = "file://" + channelPath
// Make sure any platform-specific separators that aren't /, are converted to / for use in a file: protocol URL
kops.DefaultChannelBase = "file://" + filepath.ToSlash(channelPath)
} }
return h return h