11/*
2- Copyright The containerd Authors.
3- Licensed under the Apache License, Version 2.0 (the "License");
4- you may not use this file except in compliance with the License.
5- You may obtain a copy of the License at
2+ Copyright The containerd Authors.
63
7- http://www.apache.org/licenses/LICENSE-2.0
4+ Licensed under the Apache License, Version 2.0 (the "License");
5+ you may not use this file except in compliance with the License.
6+ You may obtain a copy of the License at
87
9- Unless required by applicable law or agreed to in writing, software
10- distributed under the License is distributed on an "AS IS" BASIS,
11- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12- See the License for the specific language governing permissions and
13- limitations under the License.
8+ http://www.apache.org/licenses/LICENSE-2.0
9+
10+ Unless required by applicable law or agreed to in writing, software
11+ distributed under the License is distributed on an "AS IS" BASIS,
12+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ See the License for the specific language governing permissions and
14+ limitations under the License.
1415*/
16+
1517package container
1618
1719import (
1820 "fmt"
1921 "strings"
2022 "testing"
2123
24+ "gotest.tools/v3/assert"
25+
26+ "github.com/containerd/nerdctl/mod/tigron/expect"
2227 "github.com/containerd/nerdctl/mod/tigron/require"
2328 "github.com/containerd/nerdctl/mod/tigron/test"
2429 "github.com/containerd/nerdctl/mod/tigron/tig"
30+
2531 "github.com/containerd/nerdctl/v2/pkg/formatter"
2632 "github.com/containerd/nerdctl/v2/pkg/strutil"
2733 "github.com/containerd/nerdctl/v2/pkg/tabutil"
2834 "github.com/containerd/nerdctl/v2/pkg/testutil"
2935 "github.com/containerd/nerdctl/v2/pkg/testutil/nerdtest"
30- "gotest.tools/v3/assert"
3136)
3237
3338func setupPsTestContainer (identity string , restart bool , hyperv bool ) func (data test.Data , helpers test.Helpers ) {
@@ -78,7 +83,7 @@ func TestListProcessContainer(t *testing.T) {
7883 }
7984 testCase .Expected = func (data test.Data , helpers test.Helpers ) * test.Expected {
8085 return & test.Expected {
81- ExitCode : 0 ,
86+ ExitCode : expect . ExitCodeSuccess ,
8287 Output : func (stdout string , t tig.T ) {
8388 lines := strings .Split (strings .TrimSpace (stdout ), "\n " )
8489 assert .Assert (t , len (lines ) >= 2 , fmt .Sprintf ("expected at least 2 lines, got %d" , len (lines )))
@@ -90,8 +95,11 @@ func TestListProcessContainer(t *testing.T) {
9095 image , _ := tab .ReadRow (lines [1 ], "IMAGE" )
9196 assert .Equal (t , image , testutil .NginxAlpineImage )
9297 size , _ := tab .ReadRow (lines [1 ], "SIZE" )
93- assert .Assert (t , strings .Contains (size , "(virtual" ),
94- fmt .Sprintf ("expect container size to contain '(virtual', but got %s" , size ))
98+ assert .Assert (
99+ t ,
100+ strings .Contains (size , "(virtual" ),
101+ fmt .Sprintf ("expect container size to contain '(virtual', but got %s" , size ),
102+ )
95103 },
96104 }
97105 }
@@ -114,7 +122,7 @@ func TestListHyperVContainer(t *testing.T) {
114122 }
115123 testCase .Expected = func (data test.Data , helpers test.Helpers ) * test.Expected {
116124 return & test.Expected {
117- ExitCode : 0 ,
125+ ExitCode : expect . ExitCodeSuccess ,
118126 Output : func (stdout string , t tig.T ) {
119127 lines := strings .Split (strings .TrimSpace (stdout ), "\n " )
120128 assert .Assert (t , len (lines ) >= 2 , fmt .Sprintf ("expected at least 2 lines, got %d" , len (lines )))
@@ -144,7 +152,7 @@ func TestListProcessContainerWideMode(t *testing.T) {
144152 }
145153 testCase .Expected = func (data test.Data , helpers test.Helpers ) * test.Expected {
146154 return & test.Expected {
147- ExitCode : 0 ,
155+ ExitCode : expect . ExitCodeSuccess ,
148156 Output : func (stdout string , t tig.T ) {
149157 lines := strings .Split (strings .TrimSpace (stdout ), "\n " )
150158 assert .Assert (t , len (lines ) >= 2 , fmt .Sprintf ("expected at least 2 lines, got %d" , len (lines )))
@@ -175,7 +183,7 @@ func TestListProcessContainerWithLabels(t *testing.T) {
175183 }
176184 testCase .Expected = func (data test.Data , helpers test.Helpers ) * test.Expected {
177185 return & test.Expected {
178- ExitCode : 0 ,
186+ ExitCode : expect . ExitCodeSuccess ,
179187 Output : func (stdout string , t tig.T ) {
180188 lines := strings .Split (strings .TrimSpace (stdout ), "\n " )
181189 assert .Assert (t , len (lines ) == 1 , fmt .Sprintf ("expected 1 line, got %d" , len (lines )))
0 commit comments