Skip to content

Commit 64a1458

Browse files
committed
tests: diskusage command
Signed-off-by: CrazyMax <[email protected]>
1 parent 4afbd68 commit 64a1458

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

tests/diskusage.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package tests
2+
3+
import (
4+
"encoding/json"
5+
"testing"
6+
7+
"github.com/moby/buildkit/client"
8+
"github.com/moby/buildkit/util/testutil/integration"
9+
"github.com/stretchr/testify/require"
10+
)
11+
12+
var diskusageTests = []func(t *testing.T, sb integration.Sandbox){
13+
testDiskusage,
14+
testDiskusageVerboseRaw,
15+
testDiskusageVerboseJSON,
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 testDiskusageVerboseRaw(t *testing.T, sb integration.Sandbox) {
26+
buildTestProject(t, sb)
27+
cmd := buildxCmd(sb, withArgs("du", "--verbose", "--format=raw"))
28+
out, err := cmd.Output()
29+
require.NoError(t, err, string(out))
30+
}
31+
32+
func testDiskusageVerboseJSON(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.NoError(t, err, string(out))
37+
38+
var du []*client.UsageInfo
39+
err = json.Unmarshal(out, &du)
40+
require.NoError(t, err)
41+
require.NotEmpty(t, du)
42+
}

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)