@@ -18,11 +18,15 @@ package initializer
18
18
19
19
import (
20
20
"bytes"
21
+ "context"
21
22
"strings"
22
23
"testing"
23
24
25
+ "github.com/pkg/errors"
26
+
24
27
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/docker"
25
28
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/jib"
29
+ "github.com/GoogleContainerTools/skaffold/pkg/skaffold/util"
26
30
"github.com/GoogleContainerTools/skaffold/testutil"
27
31
)
28
32
@@ -612,3 +616,42 @@ func Test_canonicalizeName(t *testing.T) {
612
616
})
613
617
}
614
618
}
619
+
620
+ func TestRunKompose (t * testing.T ) {
621
+ tests := []struct {
622
+ description string
623
+ composeFile string
624
+ commands util.Command
625
+ expectedError string
626
+ }{
627
+ {
628
+ description : "success" ,
629
+ composeFile : "docker-compose.yaml" ,
630
+ commands : testutil .CmdRunOut ("kompose convert -f docker-compose.yaml" , "" ),
631
+ },
632
+ {
633
+ description : "not found" ,
634
+ composeFile : "not-found.yaml" ,
635
+ expectedError : "(no such file or directory|cannot find the file specified)" ,
636
+ },
637
+ {
638
+ description : "failure" ,
639
+ composeFile : "docker-compose.yaml" ,
640
+ commands : testutil .CmdRunOutErr ("kompose convert -f docker-compose.yaml" , "" , errors .New ("BUG" )),
641
+ expectedError : "BUG" ,
642
+ },
643
+ }
644
+
645
+ for _ , test := range tests {
646
+ testutil .Run (t , test .description , func (t * testutil.T ) {
647
+ t .NewTempDir ().Touch ("docker-compose.yaml" ).Chdir ()
648
+ t .Override (& util .DefaultExecCommand , test .commands )
649
+
650
+ err := runKompose (context .Background (), test .composeFile )
651
+
652
+ if test .expectedError != "" {
653
+ t .CheckMatches (test .expectedError , err .Error ())
654
+ }
655
+ })
656
+ }
657
+ }
0 commit comments