Skip to content

Commit f0646ee

Browse files
committed
tests: diskusage command
Signed-off-by: CrazyMax <[email protected]>
1 parent b6baad4 commit f0646ee

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

tests/diskusage.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package tests
2+
3+
import (
4+
"testing"
5+
6+
"github.com/moby/buildkit/util/testutil/integration"
7+
"github.com/stretchr/testify/require"
8+
)
9+
10+
var diskusageTests = []func(t *testing.T, sb integration.Sandbox){
11+
testDiskusage,
12+
testDiskusageVerbose,
13+
testDiskusageVerboseFormatError,
14+
testDiskusageFormatJSON,
15+
testDiskusageFormatGoTemplate,
16+
}
17+
18+
func testDiskusage(t *testing.T, sb integration.Sandbox) {
19+
buildTestProject(t, sb)
20+
cmd := buildxCmd(sb, withArgs("du"))
21+
out, err := cmd.Output()
22+
require.NoError(t, err, string(out))
23+
}
24+
25+
func testDiskusageVerbose(t *testing.T, sb integration.Sandbox) {
26+
buildTestProject(t, sb)
27+
cmd := buildxCmd(sb, withArgs("du", "--verbose"))
28+
out, err := cmd.Output()
29+
require.NoError(t, err, string(out))
30+
}
31+
32+
func testDiskusageVerboseFormatError(t *testing.T, sb integration.Sandbox) {
33+
buildTestProject(t, sb)
34+
cmd := buildxCmd(sb, withArgs("du", "--verbose", "--format=json"))
35+
out, err := cmd.Output()
36+
require.Error(t, err, string(out))
37+
}
38+
39+
func testDiskusageFormatJSON(t *testing.T, sb integration.Sandbox) {
40+
buildTestProject(t, sb)
41+
cmd := buildxCmd(sb, withArgs("du", "--format=json"))
42+
out, err := cmd.Output()
43+
require.NoError(t, err, string(out))
44+
}
45+
46+
func testDiskusageFormatGoTemplate(t *testing.T, sb integration.Sandbox) {
47+
buildTestProject(t, sb)
48+
cmd := buildxCmd(sb, withArgs("du", "--format={{.ID}}: {{.Size}}"))
49+
out, err := cmd.Output()
50+
require.NoError(t, err, string(out))
51+
}

tests/integration_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func TestIntegration(t *testing.T) {
3333
tests = append(tests, rmTests...)
3434
tests = append(tests, dialstdioTests...)
3535
tests = append(tests, composeTests...)
36+
tests = append(tests, diskusageTests...)
3637
testIntegration(t, tests...)
3738
}
3839

0 commit comments

Comments
 (0)