You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Copyright 2021 The Gitea Authors. All rights reserved.
2
+
// Use of this source code is governed by a MIT-style
3
+
// license that can be found in the LICENSE file.
4
+
5
+
package unittestbridge
6
+
7
+
// Usage: generally, non-unit-test code shouldn't depend on unit test code.
8
+
// However, we have some code like models.CheckConsistencyFor, which need to do some unit test works.
9
+
// Now we can not decouple models.CheckConsistencyFor from unit test code easily (cycle-import reasons).
10
+
// So we introduce this `unit test bridge`:
11
+
// * When a release binary is built, no testing/assert framework would be compiled into the binary, and CheckConsistencyFor won't run unit test related code
12
+
// * When a unit test binary is built, the unit test code will init this bridge, then CheckConsistencyFor can run unit test related code
13
+
//
14
+
// Tester/Assert are intermediate interfaces, they should NOT be used in new code.
15
+
// One day, if CheckConsistencyFor is clean enough, we can remove these intermediate interfaces.
16
+
17
+
// Tester is the same as TestingT in "stretchr/testify/assert"
18
+
// Tester can be used in non-unit-test code (ex: models.CheckConsistencyFor), it is used to isolate dependencies
19
+
typeTesterinterface {
20
+
Errorf(formatstring, args...interface{})
21
+
}
22
+
23
+
// Asserter can be used in non-unit-test code (ex: models.CheckConsistencyFor), it is used to isolate dependencies
0 commit comments