mirror of https://github.com/go-gitea/gitea.git
archiver: tests: Test* is run in a separate context than TestMain
We must setup the mutex/cond variables at the beginning of any test that's going to use it, or else these will be nil when the test is actually ran.
This commit is contained in:
parent
759b4d1eec
commit
be77f9ed59
|
@ -21,10 +21,6 @@ var queueMutex sync.Mutex
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
models.MainTest(m, filepath.Join("..", ".."))
|
models.MainTest(m, filepath.Join("..", ".."))
|
||||||
|
|
||||||
archiveQueueMutex = &queueMutex
|
|
||||||
archiveQueueStartCond = sync.NewCond(&queueMutex)
|
|
||||||
archiveQueueReleaseCond = sync.NewCond(&queueMutex)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func allComplete(inFlight []*ArchiveRequest) bool {
|
func allComplete(inFlight []*ArchiveRequest) bool {
|
||||||
|
@ -79,6 +75,15 @@ func releaseOneEntry(t *testing.T, inFlight []*ArchiveRequest) {
|
||||||
func TestArchive_Basic(t *testing.T) {
|
func TestArchive_Basic(t *testing.T) {
|
||||||
assert.NoError(t, models.PrepareTestDatabase())
|
assert.NoError(t, models.PrepareTestDatabase())
|
||||||
|
|
||||||
|
archiveQueueMutex = &queueMutex
|
||||||
|
archiveQueueStartCond = sync.NewCond(&queueMutex)
|
||||||
|
archiveQueueReleaseCond = sync.NewCond(&queueMutex)
|
||||||
|
defer func() {
|
||||||
|
archiveQueueMutex = nil
|
||||||
|
archiveQueueStartCond = nil
|
||||||
|
archiveQueueReleaseCond = nil
|
||||||
|
}()
|
||||||
|
|
||||||
ctx := test.MockContext(t, "user27/repo49")
|
ctx := test.MockContext(t, "user27/repo49")
|
||||||
firstCommit, secondCommit := "51f84af23134", "aacbdfe9e1c4"
|
firstCommit, secondCommit := "51f84af23134", "aacbdfe9e1c4"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue