Skip to content

Commit bf0c532

Browse files
committed
fix tests and lints for ObjectStorage
1 parent 75af3b6 commit bf0c532

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

modules/storage/local_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,27 +57,27 @@ func TestLocalStorageIterator(t *testing.T) {
5757
l, err := NewLocalStorage(context.Background(), LocalStorageConfig{Path: "testdata/"})
5858
assert.NoError(t, err)
5959

60-
test_files := [][]string{
60+
testFiles := [][]string{
6161
{"a/1.txt", "a1"},
6262
{"/a/1.txt", "aa1"}, // same as above, but with leading slash that will be trim
6363
{"b/1.txt", "b1"},
6464
{"b/2.txt", "b2"},
6565
{"b/3.txt", "b3"},
6666
{"b/x 4.txt", "bx4"},
6767
}
68-
for _, f := range test_files {
68+
for _, f := range testFiles {
6969
_, err = l.Save(f[0], bytes.NewBufferString(f[1]), -1)
7070
assert.NoError(t, err)
7171
}
7272

73-
expected_list := map[string][]string{
73+
expectedList := map[string][]string{
7474
"a": {"a/1.txt"},
7575
"b": {"b/1.txt", "b/2.txt", "b/3.txt", "b/x 4.txt"},
7676
"": {"a/1.txt", "b/1.txt", "b/2.txt", "b/3.txt", "b/x 4.txt"},
7777
"/": {"a/1.txt", "b/1.txt", "b/2.txt", "b/3.txt", "b/x 4.txt"},
7878
"a/b/../../a": {"a/1.txt"},
7979
}
80-
for dir, expected := range expected_list {
80+
for dir, expected := range expectedList {
8181
count := 0
8282
err = l.IterateObjects(dir, func(path string, f Object) error {
8383
defer f.Close()
@@ -90,12 +90,12 @@ func TestLocalStorageIterator(t *testing.T) {
9090
}
9191

9292
// illegal dir
93-
illegal_dirs := []string{
93+
illegalDirs := []string{
9494
"../a",
9595
"../../etc/hosts",
9696
"../a/../b",
9797
}
98-
for _, dir := range illegal_dirs {
98+
for _, dir := range illegalDirs {
9999
err = l.IterateObjects(dir, func(path string, f Object) error {
100100
defer f.Close()
101101
return nil

tests/test_utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ func PrepareTestEnv(t testing.TB, skip ...int) func() {
201201
lfsFixtures, err := storage.NewStorage("", storage.LocalStorageConfig{Path: path.Join(filepath.Dir(setting.AppPath), "tests/gitea-lfs-meta")})
202202
assert.NoError(t, err)
203203
assert.NoError(t, storage.Clean(storage.LFS))
204-
assert.NoError(t, lfsFixtures.IterateObjects(func(path string, _ storage.Object) error {
204+
assert.NoError(t, lfsFixtures.IterateObjects("", func(path string, _ storage.Object) error {
205205
_, err := storage.Copy(storage.LFS, path, lfsFixtures, path)
206206
return err
207207
}))
@@ -258,7 +258,7 @@ func ResetFixtures(t *testing.T) {
258258
lfsFixtures, err := storage.NewStorage("", storage.LocalStorageConfig{Path: path.Join(filepath.Dir(setting.AppPath), "tests/gitea-lfs-meta")})
259259
assert.NoError(t, err)
260260
assert.NoError(t, storage.Clean(storage.LFS))
261-
assert.NoError(t, lfsFixtures.IterateObjects(func(path string, _ storage.Object) error {
261+
assert.NoError(t, lfsFixtures.IterateObjects("", func(path string, _ storage.Object) error {
262262
_, err := storage.Copy(storage.LFS, path, lfsFixtures, path)
263263
return err
264264
}))

0 commit comments

Comments
 (0)