mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2025-06-18 18:16:26 +00:00
Add more unit tests
This commit is contained in:
@ -1,7 +1,10 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
"npm/internal/config"
|
||||
"npm/internal/database"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/DATA-DOG/go-sqlmock"
|
||||
"gorm.io/driver/postgres"
|
||||
@ -21,3 +24,18 @@ func Setup() (sqlmock.Sqlmock, error) {
|
||||
database.SetDB(gormDB)
|
||||
return mock, err
|
||||
}
|
||||
|
||||
func InitConfig(t *testing.T, envs ...string) {
|
||||
if len(envs) > 0 {
|
||||
for _, env := range envs {
|
||||
parts := strings.Split(env, "=")
|
||||
if len(parts) == 2 {
|
||||
t.Setenv(parts[0], parts[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
version := "999.999.999"
|
||||
commit := "abcd123"
|
||||
config.Init(&version, &commit)
|
||||
}
|
||||
|
Reference in New Issue
Block a user