Skip to content

Commit 32c541f

Browse files
authored
Merge pull request #75 from AkihiroSuda/dev-ci
add more tests
2 parents b91309b + bd52ed0 commit 32c541f

File tree

2 files changed

+41
-4
lines changed

2 files changed

+41
-4
lines changed

image_convert_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
Copyright (C) nerdctl authors.
3+
Copyright (C) containerd authors.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
*/
17+
18+
package main
19+
20+
import (
21+
"testing"
22+
23+
"github.com/AkihiroSuda/nerdctl/pkg/testutil"
24+
)
25+
26+
func TestImageConvertEStargz(t *testing.T) {
27+
testutil.DockerIncompatible(t)
28+
base := testutil.NewBase(t)
29+
convertedImage := "test-image-convert:esgz"
30+
base.Cmd("rmi", convertedImage).Run()
31+
defer base.Cmd("rmi", convertedImage).Run()
32+
base.Cmd("pull", testutil.AlpineImage).AssertOK()
33+
base.Cmd("image", "convert", "--estargz", "--oci",
34+
testutil.AlpineImage, convertedImage).AssertOK()
35+
}

pkg/testutil/testutil.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,10 @@ func (b *Base) EnsureDaemonActive() {
111111
type Cmd struct {
112112
icmd.Cmd
113113
*Base
114-
DockerIncompatible bool
115114
}
116115

117116
func (c *Cmd) Run() *icmd.Result {
118117
c.Base.T.Helper()
119-
if c.Base.Target == Docker && c.DockerIncompatible {
120-
c.Base.T.Skip("test is incompatible with Docker")
121-
}
122118
return icmd.RunCmd(c.Cmd)
123119
}
124120

@@ -180,6 +176,12 @@ func GetDaemonIsKillable() bool {
180176
return flagTestKillDaemon
181177
}
182178

179+
func DockerIncompatible(t testing.TB) {
180+
if GetTarget() == Docker {
181+
t.Skip("test is incompatible with Docker")
182+
}
183+
}
184+
183185
const Namespace = "nerdctl-test"
184186

185187
func NewBase(t *testing.T) *Base {

0 commit comments

Comments
 (0)