Skip to content

Commit 541acb6

Browse files
committed
Add skeleton for minikube image integration test
1 parent 943561b commit 541acb6

File tree

4 files changed

+74
-0
lines changed

4 files changed

+74
-0
lines changed

test/integration/image_test.go

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// +build integration
2+
3+
/*
4+
Copyright 2021 The Kubernetes Authors All rights reserved.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package integration
20+
21+
import (
22+
"context"
23+
"os/exec"
24+
"path/filepath"
25+
"testing"
26+
)
27+
28+
// TestImage tests minikube image
29+
func TestImage(t *testing.T) {
30+
profile := UniqueProfileName("image")
31+
ctx, cancel := context.WithTimeout(context.Background(), Minutes(5))
32+
defer CleanupWithLogs(t, profile, cancel)
33+
34+
args := append([]string{"start", "-p", profile, "--memory=2048"}, StartArgs()...)
35+
rr, err := Run(t, exec.CommandContext(ctx, Target(), args...))
36+
if err != nil {
37+
t.Fatalf("starting minikube: %v\n%s", err, rr.Output())
38+
}
39+
40+
tests := []struct {
41+
command string
42+
args []string
43+
}{
44+
{
45+
command: "image",
46+
args: []string{"load", filepath.Join(*testdataDir, "hello-world.tar")},
47+
}, {
48+
command: "image",
49+
args: []string{"list"},
50+
}, {
51+
command: "image",
52+
args: []string{"rm", "hello-world"},
53+
}, {
54+
command: "image",
55+
args: []string{"build", filepath.Join(*testdataDir, "build")},
56+
},
57+
}
58+
59+
for _, test := range tests {
60+
t.Run(test.command, func(t *testing.T) {
61+
args := []string{test.command, "-p", profile}
62+
args = append(args, test.args...)
63+
64+
rr, err := Run(t, exec.CommandContext(ctx, Target(), args...))
65+
if err != nil {
66+
t.Errorf("failed to clean up: args %q: %v", rr.Command(), err)
67+
}
68+
})
69+
}
70+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM busybox
2+
RUN true
3+
ADD content.txt /
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Content for image build
24 KB
Binary file not shown.

0 commit comments

Comments
 (0)