4cddfcf2f3
Backend Tests / Tests (other) (push) Failing after 1s
Backend Tests / Static Checks (push) Failing after 2s
Backend Tests / Tests (internal) (push) Failing after 2s
Backend Tests / Tests (server) (push) Failing after 1s
Backend Tests / Tests (store) (push) Failing after 1s
Build Canary Image / build-frontend (push) Failing after 1s
Frontend Tests / Lint (push) Failing after 1s
Build Canary Image / build-push (linux/amd64) (push) Has been skipped
Build Canary Image / build-push (linux/arm64) (push) Has been skipped
Build Canary Image / merge (push) Has been skipped
Frontend Tests / Build (push) Failing after 1s
Release Please / release-please (push) Failing after 0s
Proto Linter / Lint Protos (push) Failing after 2s
35 lines
966 B
Go
35 lines
966 B
Go
package v1
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestWalkLocalStorage_SumsFileSizes(t *testing.T) {
|
|
dir := t.TempDir()
|
|
require.NoError(t, os.WriteFile(filepath.Join(dir, "a.txt"), []byte("hello"), 0o600)) // 5
|
|
require.NoError(t, os.WriteFile(filepath.Join(dir, "b.txt"), []byte("world!"), 0o600)) // 6
|
|
sub := filepath.Join(dir, "sub")
|
|
require.NoError(t, os.Mkdir(sub, 0o700))
|
|
require.NoError(t, os.WriteFile(filepath.Join(sub, "c.txt"), []byte("xx"), 0o600)) // 2
|
|
|
|
size, err := walkLocalStorage(dir)
|
|
require.NoError(t, err)
|
|
require.Equal(t, int64(13), size)
|
|
}
|
|
|
|
func TestWalkLocalStorage_EmptyDir(t *testing.T) {
|
|
size, err := walkLocalStorage("")
|
|
require.Error(t, err)
|
|
require.Equal(t, int64(-1), size)
|
|
}
|
|
|
|
func TestWalkLocalStorage_NonexistentDir(t *testing.T) {
|
|
size, err := walkLocalStorage(filepath.Join(t.TempDir(), "does-not-exist"))
|
|
require.Error(t, err)
|
|
require.Equal(t, int64(-1), size)
|
|
}
|