This repository has been archived by the owner on Mar 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
version_compatibility_test.go
67 lines (56 loc) · 2.06 KB
/
version_compatibility_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
import (
"path/filepath"
"strings"
"testing"
)
func assertRetoolDoWorks(t *testing.T, wd string, retoolBin string) {
output := runRetoolCmd(t, wd, retoolBin, "do", "retool_test_app")
want := "v1"
if strings.TrimSpace(output) != want {
t.Errorf("'retool do' gave unexpected output, have=%q want=%q", output, want)
}
}
// TestCompatibility tests that the current version of retool is compatible with
// old versions. It should set up projects that are readable by old versions,
// and it should be able to read projects set up by old versions.
func TestCompatibility(t *testing.T) {
newRetool, err := buildRetool()
if err != nil {
t.Fatalf("unable to build current retool version: %s", err)
}
compatibilityTest := func(oldVersion string) {
t.Run(oldVersion, func(t *testing.T) {
t.Parallel()
// Install old version
installDir, installCleanup := setupTempDir(t)
defer installCleanup()
runRetoolCmd(t, installDir, newRetool, "add", "github.com/twitchtv/retool", oldVersion)
oldRetool := filepath.Join(installDir, "_tools", "bin", "retool"+osBinSuffix)
t.Run("parallel tests", func(t *testing.T) {
// The extra t.Run("parallel tests" grouping here is necessary to make
// sure that 'defer installCleanup()' gets run *after* these two
// subtests run.
t.Run("project set up with "+oldVersion, func(t *testing.T) {
t.Parallel()
project, cleanup := setupTempDir(t)
defer cleanup()
runRetoolCmd(t, project, oldRetool, "add", "github.com/spenczar/retool_test_app", "v1")
runRetoolCmd(t, project, oldRetool, "sync")
assertRetoolDoWorks(t, project, newRetool)
})
t.Run("project set up with new version", func(t *testing.T) {
t.Parallel()
project, cleanup := setupTempDir(t)
defer cleanup()
runRetoolCmd(t, project, newRetool, "add", "github.com/spenczar/retool_test_app", "v1")
runRetoolCmd(t, project, newRetool, "sync")
assertRetoolDoWorks(t, project, oldRetool)
})
})
})
}
compatibilityTest("v1.2.0")
compatibilityTest("v1.1.0")
compatibilityTest("v1.0.3")
}