|
| 1 | +// Copyright (C) 2019-2022 Algorand, Inc. |
| 2 | +// This file is part of go-algorand |
| 3 | +// |
| 4 | +// go-algorand is free software: you can redistribute it and/or modify |
| 5 | +// it under the terms of the GNU Affero General Public License as |
| 6 | +// published by the Free Software Foundation, either version 3 of the |
| 7 | +// License, or (at your option) any later version. |
| 8 | +// |
| 9 | +// go-algorand is distributed in the hope that it will be useful, |
| 10 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | +// GNU Affero General Public License for more details. |
| 13 | +// |
| 14 | +// You should have received a copy of the GNU Affero General Public License |
| 15 | +// along with go-algorand. If not, see <https://www.gnu.org/licenses/>. |
| 16 | + |
| 17 | +package util |
| 18 | + |
| 19 | +import ( |
| 20 | + "os" |
| 21 | + "path" |
| 22 | + "testing" |
| 23 | + |
| 24 | + "github.com/stretchr/testify/assert" |
| 25 | + |
| 26 | + "github.com/algorand/go-algorand/test/partitiontest" |
| 27 | +) |
| 28 | + |
| 29 | +func TestIsEmpty(t *testing.T) { |
| 30 | + partitiontest.PartitionTest(t) |
| 31 | + |
| 32 | + testPath := path.Join(os.TempDir(), "this", "is", "a", "long", "path") |
| 33 | + err := os.MkdirAll(testPath, os.ModePerm) |
| 34 | + assert.NoError(t, err) |
| 35 | + defer os.RemoveAll(testPath) |
| 36 | + assert.True(t, IsEmpty(testPath)) |
| 37 | + |
| 38 | + _, err = os.Create(path.Join(testPath, "file.txt")) |
| 39 | + assert.NoError(t, err) |
| 40 | + assert.False(t, IsEmpty(testPath)) |
| 41 | +} |
0 commit comments