Adding changes to separate unit tests and integration tests (#13670)

* Introducing unit (not integration) tests for the app layer

* Initial support for unit tests at the API

* Adding unit tests support to the store layer

* Add unit tests support in commands

* Adding last tests needed for run unit tests properly

* Fixing govet

* Removing some duplication

* Fixing tests

* Fixing tests

* Not compiling test helpers with the main module for api

* Revert "Not compiling test helpers with the main module for api"

This reverts commit 36a199bbe0f7503f665f5d6c7b41c53aabc2e54f.

* Fixing tests

* Fixing unit tests

* More consistency between api4/apiteslib.go and app/helper_test.go

* Renaming things to make more obvious the new Setup functions purpose

* Reverting change in go.sum

* Start with empty mock for app layer

* Start with empty mock for api layer

* Start with empty mock for web layer

* Renaming SetupWithStoreMockConfig to SetupConfigWithStoreMock

* Fixing tests on web package

* Removing unnecesary function
Этот коммит содержится в:
Jesús Espino
2020-03-02 17:13:39 +01:00
коммит произвёл GitHub
родитель cd36c9f041
Коммит 7035e09fe9
27 изменённых файлов: 720 добавлений и 187 удалений

Просмотреть файл

@@ -27,6 +27,9 @@ func getDsn(driver string, source string) string {
}
func setupConfigDatabase(t *testing.T, cfg *model.Config, files map[string][]byte) (string, func()) {
if testing.Short() {
t.SkipNow()
}
t.Helper()
os.Clearenv()
truncateTables(t)
@@ -112,6 +115,9 @@ func assertDatabaseNotEqualsConfig(t *testing.T, expectedCfg *model.Config) {
}
func TestDatabaseStoreNew(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
sqlSettings := mainHelper.GetSQLSettings()
t.Run("no existing configuration - initialization required", func(t *testing.T) {
@@ -331,6 +337,9 @@ func TestDatabaseStoreGetEnivironmentOverrides(t *testing.T) {
}
func TestDatabaseStoreSet(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
sqlSettings := mainHelper.GetSQLSettings()
t.Run("set same pointer value", func(t *testing.T) {
@@ -540,6 +549,9 @@ func TestDatabaseStoreSet(t *testing.T) {
}
func TestDatabaseStoreLoad(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
sqlSettings := mainHelper.GetSQLSettings()
t.Run("active configuration no longer exists", func(t *testing.T) {
@@ -979,6 +991,9 @@ func TestDatabaseRemoveFile(t *testing.T) {
}
func TestDatabaseStoreString(t *testing.T) {
if testing.Short() {
t.SkipNow()
}
_, tearDown := setupConfigDatabase(t, emptyConfig, nil)
defer tearDown()