@@ -35,20 +35,15 @@ func TestImageBuild(t *testing.T) {
35
35
type validateFunc func (context.Context , * testing.T , string )
36
36
profile := UniqueProfileName ("image" )
37
37
ctx , cancel := context .WithTimeout (context .Background (), Minutes (15 ))
38
- startArgs := []string {"start" , "-p" , profile }
39
- startArgs = append (startArgs , StartArgs ()... )
40
- rr , err := Run (t , exec .CommandContext (ctx , Target (), startArgs ... ))
41
38
defer Cleanup (t , profile , cancel )
42
- if err != nil {
43
- t .Fatalf ("failed to start minikube with args: %q : %v" , rr .Command (), err )
44
- }
45
39
46
40
// Serial tests
47
41
t .Run ("serial" , func (t * testing.T ) {
48
42
tests := []struct {
49
43
name string
50
44
validator validateFunc
51
45
}{
46
+ {"Setup" , validateSetupImageBuild },
52
47
{"NormalBuild" , validateNormalImageBuild },
53
48
{"BuildWithBuildArg" , validateImageBuildWithBuildArg },
54
49
{"BuildWithDockerIgnore" , validateImageBuildWithDockerIgnore },
@@ -58,14 +53,24 @@ func TestImageBuild(t *testing.T) {
58
53
for _ , tc := range tests {
59
54
t .Run (tc .name , func (t * testing.T ) {
60
55
tc .validator (ctx , t , profile )
61
- if t .Failed () && * postMortemLogs {
62
- PostMortemLogs (t , profile )
63
- }
64
56
})
57
+ // if setup fails bail
58
+ if tc .name == "Setup" && t .Failed () {
59
+ return
60
+ }
65
61
}
66
62
})
67
63
}
68
64
65
+ // validateSetupImageBuild starts a cluster for the image builds
66
+ func validateSetupImageBuild (ctx context.Context , t * testing.T , profile string ) {
67
+ defer PostMortemLogs (t , profile )
68
+ startArgs := append ([]string {"start" , "-p" , profile }, StartArgs ()... )
69
+ if rr , err := Run (t , exec .CommandContext (ctx , Target (), startArgs ... )); err != nil {
70
+ t .Fatalf ("failed to start minikube with args: %q : %v" , rr .Command (), err )
71
+ }
72
+ }
73
+
69
74
// validateNormalImageBuild is normal test case for minikube image build, with -t parameter
70
75
func validateNormalImageBuild (ctx context.Context , t * testing.T , profile string ) {
71
76
defer PostMortemLogs (t , profile )
0 commit comments