Skip to content

Commit cdfb086

Browse files
committed
improve tests
1 parent c1699cf commit cdfb086

File tree

4 files changed

+9
-20
lines changed

4 files changed

+9
-20
lines changed

models/unittest/fixtures_loader.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
"xorm.io/xorm/schemas"
2020
)
2121

22-
type fixtureItem struct {
22+
type FixtureItem struct {
2323
fileFullPath string
2424
tableName string
2525

@@ -35,7 +35,7 @@ type fixturesLoaderInternal struct {
3535
xormTableNames map[string]bool
3636
db *sql.DB
3737
dbType schemas.DBType
38-
fixtures map[string]*fixtureItem
38+
fixtures map[string]*FixtureItem
3939
quoteObject func(string) string
4040
paramPlaceholder func(idx int) string
4141
}
@@ -64,7 +64,7 @@ func (f *fixturesLoaderInternal) preprocessFixtureRow(row []map[string]any) (err
6464
return nil
6565
}
6666

67-
func (f *fixturesLoaderInternal) prepareFixtureItem(fixture *fixtureItem) (err error) {
67+
func (f *fixturesLoaderInternal) prepareFixtureItem(fixture *FixtureItem) (err error) {
6868
fixture.tableNameQuoted = f.quoteObject(fixture.tableName)
6969

7070
if f.dbType == schemas.MSSQL {
@@ -113,7 +113,7 @@ func (f *fixturesLoaderInternal) prepareFixtureItem(fixture *fixtureItem) (err e
113113
return nil
114114
}
115115

116-
func (f *fixturesLoaderInternal) loadFixtures(tx *sql.Tx, fixture *fixtureItem) (err error) {
116+
func (f *fixturesLoaderInternal) loadFixtures(tx *sql.Tx, fixture *FixtureItem) (err error) {
117117
if fixture.tableNameQuoted == "" {
118118
if err = f.prepareFixtureItem(fixture); err != nil {
119119
return err
@@ -167,7 +167,7 @@ func (f *fixturesLoaderInternal) Load() error {
167167
return nil
168168
}
169169

170-
func FixturesFileFullPaths(dir string, files []string) (map[string]*fixtureItem, error) {
170+
func FixturesFileFullPaths(dir string, files []string) (map[string]*FixtureItem, error) {
171171
if files != nil && len(files) == 0 {
172172
return nil, nil // load nothing
173173
}
@@ -181,14 +181,14 @@ func FixturesFileFullPaths(dir string, files []string) (map[string]*fixtureItem,
181181
files = append(files, e.Name())
182182
}
183183
}
184-
fixtureItems := map[string]*fixtureItem{}
184+
fixtureItems := map[string]*FixtureItem{}
185185
for _, file := range files {
186186
fileFillPath := file
187187
if !filepath.IsAbs(fileFillPath) {
188188
fileFillPath = filepath.Join(dir, file)
189189
}
190190
tableName, _, _ := strings.Cut(filepath.Base(file), ".")
191-
fixtureItems[tableName] = &fixtureItem{fileFullPath: fileFillPath, tableName: tableName}
191+
fixtureItems[tableName] = &FixtureItem{fileFullPath: fileFillPath, tableName: tableName}
192192
}
193193
return fixtureItems, nil
194194
}

tests/integration/actions_job_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,6 @@ jobs:
166166
}
167167
})
168168
}
169-
170-
httpContext := NewAPITestContext(t, user2.Name, apiRepo.Name, auth_model.AccessTokenScopeWriteRepository)
171-
doAPIDeleteRepository(httpContext)(t)
172169
})
173170
}
174171

@@ -348,9 +345,6 @@ jobs:
348345
}
349346
})
350347
}
351-
352-
httpContext := NewAPITestContext(t, user2.Name, apiRepo.Name, auth_model.AccessTokenScopeWriteRepository)
353-
doAPIDeleteRepository(httpContext)(t)
354348
})
355349
}
356350

tests/integration/actions_log_test.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func TestDownloadTaskLogs(t *testing.T) {
3535
{
3636
treePath: ".gitea/workflows/download-task-logs-zstd.yml",
3737
fileContent: `name: download-task-logs-zstd
38-
on:
38+
on:
3939
push:
4040
paths:
4141
- '.gitea/workflows/download-task-logs-zstd.yml'
@@ -67,7 +67,7 @@ jobs:
6767
{
6868
treePath: ".gitea/workflows/download-task-logs-no-zstd.yml",
6969
fileContent: `name: download-task-logs-no-zstd
70-
on:
70+
on:
7171
push:
7272
paths:
7373
- '.gitea/workflows/download-task-logs-no-zstd.yml'
@@ -152,8 +152,5 @@ jobs:
152152
resetFunc()
153153
})
154154
}
155-
156-
httpContext := NewAPITestContext(t, user2.Name, repo.Name, auth_model.AccessTokenScopeWriteRepository)
157-
doAPIDeleteRepository(httpContext)(t)
158155
})
159156
}

tests/integration/api_repo_file_get_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ func TestAPIGetRawFileOrLFS(t *testing.T) {
4444
reqLFS := NewRequest(t, "GET", "/api/v1/repos/user2/repo1/media/"+lfs)
4545
respLFS := MakeRequestNilResponseRecorder(t, reqLFS, http.StatusOK)
4646
assert.Equal(t, testFileSizeSmall, respLFS.Length)
47-
48-
doAPIDeleteRepository(httpContext)
4947
})
5048
})
5149
}

0 commit comments

Comments
 (0)