@@ -33,7 +33,8 @@ func TestBuildBazel(t *testing.T) {
33
33
t .Override (& util .DefaultExecCommand , testutil .CmdRun ("bazel build //:app.tar" ).AndRunOut ("bazel info bazel-bin" , "bin" ))
34
34
testutil .CreateFakeImageTar ("bazel:app" , "bin/app.tar" )
35
35
36
- localDocker := docker .NewLocalDaemon (& testutil.FakeAPIClient {}, nil , false , nil )
36
+ builder := NewArtifactBuilder (fakeLocalDaemon (), nil , false )
37
+
37
38
artifact := & latest.Artifact {
38
39
Workspace : "." ,
39
40
ArtifactType : latest.ArtifactType {
@@ -42,8 +43,6 @@ func TestBuildBazel(t *testing.T) {
42
43
},
43
44
},
44
45
}
45
-
46
- builder := NewArtifactBuilder (localDocker , nil , false )
47
46
_ , err := builder .Build (context .Background (), ioutil .Discard , artifact , "img:tag" )
48
47
49
48
t .CheckNoError (err )
@@ -52,15 +51,15 @@ func TestBuildBazel(t *testing.T) {
52
51
53
52
func TestBuildBazelFailInvalidTarget (t * testing.T ) {
54
53
testutil .Run (t , "" , func (t * testutil.T ) {
54
+ builder := NewArtifactBuilder (nil , nil , false )
55
+
55
56
artifact := & latest.Artifact {
56
57
ArtifactType : latest.ArtifactType {
57
58
BazelArtifact : & latest.BazelArtifact {
58
59
BuildTarget : "//:invalid-target" ,
59
60
},
60
61
},
61
62
}
62
-
63
- builder := NewArtifactBuilder (nil , nil , false )
64
63
_ , err := builder .Build (context .Background (), ioutil .Discard , artifact , "img:tag" )
65
64
66
65
t .CheckErrorContains ("the bazel build target should end with .tar" , err )
@@ -98,3 +97,7 @@ func TestBuildImageTag(t *testing.T) {
98
97
99
98
testutil .CheckDeepEqual (t , "bazel:skaffold_example" , imageTag )
100
99
}
100
+
101
+ func fakeLocalDaemon () docker.LocalDaemon {
102
+ return docker .NewLocalDaemon (& testutil.FakeAPIClient {}, nil , false , nil )
103
+ }
0 commit comments