Browse code

integ-cli: Fix TestBuildAddBadLinks for windows

TestBuildAddBadLinks used to build a path by
concenating unix-style forward slashes. Fixed that
by providing a windows-equivalent using `runtime.GOOS`.

Signed-off-by: Ahmet Alp Balkan <ahmetalpbalkan@gmail.com>

Ahmet Alp Balkan authored on 2015/02/18 16:20:20
Showing 1 changed files
... ...
@@ -12,6 +12,7 @@ import (
12 12
 	"path/filepath"
13 13
 	"reflect"
14 14
 	"regexp"
15
+	"runtime"
15 16
 	"strconv"
16 17
 	"strings"
17 18
 	"syscall"
... ...
@@ -1568,7 +1569,21 @@ func TestBuildAddBadLinks(t *testing.T) {
1568 1568
 	}
1569 1569
 	defer os.RemoveAll(tempDir)
1570 1570
 
1571
-	symlinkTarget := fmt.Sprintf("/../../../../../../../../../../../..%s", tempDir)
1571
+	var symlinkTarget string
1572
+	if runtime.GOOS == "windows" {
1573
+		var driveLetter string
1574
+		if abs, err := filepath.Abs(tempDir); err != nil {
1575
+			t.Fatal(err)
1576
+		} else {
1577
+			driveLetter = abs[:1]
1578
+		}
1579
+		tempDirWithoutDrive := tempDir[2:]
1580
+		symlinkTarget = fmt.Sprintf(`%s:\..\..\..\..\..\..\..\..\..\..\..\..%s`, driveLetter, tempDirWithoutDrive)
1581
+	} else {
1582
+		symlinkTarget = fmt.Sprintf("/../../../../../../../../../../../..%s", tempDir)
1583
+	}
1584
+
1585
+	t.Logf("***=== %s", symlinkTarget)
1572 1586
 	tarPath := filepath.Join(ctx.Dir, "links.tar")
1573 1587
 	nonExistingFile := filepath.Join(tempDir, targetFile)
1574 1588
 	fooPath := filepath.Join(ctx.Dir, targetFile)