mirror of
https://github.com/xiaoxinpro/nginx-proxy-manager-zh.git
synced 2025-02-02 09:48:13 -05:00
Add goleak in unit tests
This commit is contained in:
parent
689bcb0077
commit
6da020aab1
@ -21,6 +21,7 @@ require (
|
|||||||
github.com/rotisserie/eris v0.5.4
|
github.com/rotisserie/eris v0.5.4
|
||||||
github.com/stretchr/testify v1.8.4
|
github.com/stretchr/testify v1.8.4
|
||||||
github.com/vrischmann/envconfig v1.3.0
|
github.com/vrischmann/envconfig v1.3.0
|
||||||
|
go.uber.org/goleak v1.3.0
|
||||||
golang.org/x/crypto v0.11.0
|
golang.org/x/crypto v0.11.0
|
||||||
gorm.io/datatypes v1.2.0
|
gorm.io/datatypes v1.2.0
|
||||||
gorm.io/driver/mysql v1.5.1
|
gorm.io/driver/mysql v1.5.1
|
||||||
|
@ -145,6 +145,8 @@ github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5t
|
|||||||
github.com/zenizh/go-capturer v0.0.0-20211219060012-52ea6c8fed04 h1:qXafrlZL1WsJW5OokjraLLRURHiw0OzKHD/RNdspp4w=
|
github.com/zenizh/go-capturer v0.0.0-20211219060012-52ea6c8fed04 h1:qXafrlZL1WsJW5OokjraLLRURHiw0OzKHD/RNdspp4w=
|
||||||
gitlab.com/jc21com/sqlite v1.22.2-0.20230527022643-b56cedb3bc85 h1:NPHauobrOymc80Euu+e0tsMyXcdtLCX5bQPKX5zsI38=
|
gitlab.com/jc21com/sqlite v1.22.2-0.20230527022643-b56cedb3bc85 h1:NPHauobrOymc80Euu+e0tsMyXcdtLCX5bQPKX5zsI38=
|
||||||
gitlab.com/jc21com/sqlite v1.22.2-0.20230527022643-b56cedb3bc85/go.mod h1:OrDj17Mggn6MhE+iPbBNf7RGKODDE9NFT0f3EwDzJqk=
|
gitlab.com/jc21com/sqlite v1.22.2-0.20230527022643-b56cedb3bc85/go.mod h1:OrDj17Mggn6MhE+iPbBNf7RGKODDE9NFT0f3EwDzJqk=
|
||||||
|
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||||
|
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0=
|
golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0=
|
||||||
|
@ -9,12 +9,16 @@ import (
|
|||||||
"npm/internal/entity/dnsprovider"
|
"npm/internal/entity/dnsprovider"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO configurable
|
// TODO configurable
|
||||||
const acmeLogFile = "/data/logs/acme.sh.log"
|
const acmeLogFile = "/data/logs/acme.sh.log"
|
||||||
|
|
||||||
func TestBuildCertRequestArgs(t *testing.T) {
|
func TestBuildCertRequestArgs(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
type want struct {
|
type want struct {
|
||||||
args []string
|
args []string
|
||||||
err error
|
err error
|
||||||
@ -195,6 +199,9 @@ func TestBuildCertRequestArgs(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetAcmeShFilePath(t *testing.T) {
|
func TestGetAcmeShFilePath(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
t.Run("basic test", func(t *testing.T) {
|
t.Run("basic test", func(t *testing.T) {
|
||||||
path, err := getAcmeShFilePath()
|
path, err := getAcmeShFilePath()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -207,6 +214,9 @@ func TestGetAcmeShFilePath(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetCommonEnvVars(t *testing.T) {
|
func TestGetCommonEnvVars(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
t.Run("basic test", func(t *testing.T) {
|
t.Run("basic test", func(t *testing.T) {
|
||||||
t.Setenv("ACMESH_CONFIG_HOME", "/data/.acme.sh/config")
|
t.Setenv("ACMESH_CONFIG_HOME", "/data/.acme.sh/config")
|
||||||
t.Setenv("ACMESH_HOME", "/data/.acme.sh")
|
t.Setenv("ACMESH_HOME", "/data/.acme.sh")
|
||||||
@ -227,6 +237,9 @@ func TestGetCommonEnvVars(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetAcmeShVersion(t *testing.T) {
|
func TestGetAcmeShVersion(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
t.Run("basic test", func(t *testing.T) {
|
t.Run("basic test", func(t *testing.T) {
|
||||||
resp := GetAcmeShVersion()
|
resp := GetAcmeShVersion()
|
||||||
// Seems like a pointless test, however when this is run in CI
|
// Seems like a pointless test, however when this is run in CI
|
||||||
|
@ -4,9 +4,13 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGetString(t *testing.T) {
|
func TestGetString(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
t.Run("basic test", func(t *testing.T) {
|
t.Run("basic test", func(t *testing.T) {
|
||||||
assert.Equal(t, "context value: Body", BodyCtxKey.String())
|
assert.Equal(t, "context value: Body", BodyCtxKey.String())
|
||||||
})
|
})
|
||||||
|
@ -10,9 +10,13 @@ import (
|
|||||||
|
|
||||||
"github.com/qri-io/jsonschema"
|
"github.com/qri-io/jsonschema"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestResultResponseJSON(t *testing.T) {
|
func TestResultResponseJSON(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
status int
|
status int
|
||||||
@ -67,6 +71,9 @@ func TestResultResponseJSON(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestResultSchemaErrorJSON(t *testing.T) {
|
func TestResultSchemaErrorJSON(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
given []jsonschema.KeyError
|
given []jsonschema.KeyError
|
||||||
@ -104,6 +111,9 @@ func TestResultSchemaErrorJSON(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestResultErrorJSON(t *testing.T) {
|
func TestResultErrorJSON(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
status int
|
status int
|
||||||
@ -146,6 +156,9 @@ func TestResultErrorJSON(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestNotFound(t *testing.T) {
|
func TestNotFound(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
t.Run("basic test", func(t *testing.T) {
|
t.Run("basic test", func(t *testing.T) {
|
||||||
r := httptest.NewRequest(http.MethodGet, "/anything", nil)
|
r := httptest.NewRequest(http.MethodGet, "/anything", nil)
|
||||||
w := httptest.NewRecorder()
|
w := httptest.NewRecorder()
|
||||||
@ -163,6 +176,9 @@ func TestNotFound(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestResultResponseText(t *testing.T) {
|
func TestResultResponseText(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
t.Run("basic test", func(t *testing.T) {
|
t.Run("basic test", func(t *testing.T) {
|
||||||
r := httptest.NewRequest(http.MethodGet, "/anything", nil)
|
r := httptest.NewRequest(http.MethodGet, "/anything", nil)
|
||||||
w := httptest.NewRecorder()
|
w := httptest.NewRecorder()
|
||||||
|
@ -8,9 +8,13 @@ import (
|
|||||||
"npm/internal/api/middleware"
|
"npm/internal/api/middleware"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAccessControl(t *testing.T) {
|
func TestAccessControl(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
})
|
})
|
||||||
|
@ -10,9 +10,13 @@ import (
|
|||||||
"npm/internal/api/middleware"
|
"npm/internal/api/middleware"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestBodyContext(t *testing.T) {
|
func TestBodyContext(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
// Create a test request with a body
|
// Create a test request with a body
|
||||||
body := []byte(`{"name": "John", "age": 30}`)
|
body := []byte(`{"name": "John", "age": 30}`)
|
||||||
req, err := http.NewRequest("POST", "/test", bytes.NewBuffer(body))
|
req, err := http.NewRequest("POST", "/test", bytes.NewBuffer(body))
|
||||||
|
@ -6,12 +6,16 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"go.uber.org/goleak"
|
||||||
|
|
||||||
"npm/internal/api/middleware"
|
"npm/internal/api/middleware"
|
||||||
"npm/internal/config"
|
"npm/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestEnforceSetup(t *testing.T) {
|
func TestEnforceSetup(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
shouldBeSetup bool
|
shouldBeSetup bool
|
||||||
|
@ -10,9 +10,13 @@ import (
|
|||||||
"npm/internal/api/middleware"
|
"npm/internal/api/middleware"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestExpansion(t *testing.T) {
|
func TestExpansion(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
t.Run("with expand query param", func(t *testing.T) {
|
t.Run("with expand query param", func(t *testing.T) {
|
||||||
req, err := http.NewRequest("GET", "/path?expand=item1,item2", nil)
|
req, err := http.NewRequest("GET", "/path?expand=item1,item2", nil)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
@ -47,6 +51,9 @@ func TestExpansion(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetExpandFromContext(t *testing.T) {
|
func TestGetExpandFromContext(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
t.Run("with context value", func(t *testing.T) {
|
t.Run("with context value", func(t *testing.T) {
|
||||||
req, err := http.NewRequest("GET", "/path", nil)
|
req, err := http.NewRequest("GET", "/path", nil)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
@ -13,9 +13,13 @@ import (
|
|||||||
"npm/internal/tags"
|
"npm/internal/tags"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestListQuery(t *testing.T) {
|
func TestListQuery(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
queryParams string
|
queryParams string
|
||||||
@ -61,6 +65,9 @@ func TestListQuery(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetFiltersFromContext(t *testing.T) {
|
func TestGetFiltersFromContext(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
req, err := http.NewRequest("GET", "/test", nil)
|
req, err := http.NewRequest("GET", "/test", nil)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
@ -75,6 +82,9 @@ func TestGetFiltersFromContext(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetSortFromContext(t *testing.T) {
|
func TestGetSortFromContext(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
req, err := http.NewRequest("GET", "/test", nil)
|
req, err := http.NewRequest("GET", "/test", nil)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"npm/internal/config"
|
"npm/internal/config"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -25,6 +26,12 @@ func TestMain(m *testing.M) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetHealthz(t *testing.T) {
|
func TestGetHealthz(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t,
|
||||||
|
goleak.IgnoreAnyFunction("github.com/patrickmn/go-cache.(*janitor).Run"),
|
||||||
|
goleak.IgnoreAnyFunction("github.com/jc21/go-sse.(*Server).dispatch"),
|
||||||
|
)
|
||||||
|
|
||||||
respRec := httptest.NewRecorder()
|
respRec := httptest.NewRecorder()
|
||||||
req, _ := http.NewRequest("GET", "/api/", nil)
|
req, _ := http.NewRequest("GET", "/api/", nil)
|
||||||
|
|
||||||
@ -34,6 +41,12 @@ func TestGetHealthz(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestNonExistent(t *testing.T) {
|
func TestNonExistent(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t,
|
||||||
|
goleak.IgnoreAnyFunction("github.com/patrickmn/go-cache.(*janitor).Run"),
|
||||||
|
goleak.IgnoreAnyFunction("github.com/jc21/go-sse.(*Server).dispatch"),
|
||||||
|
)
|
||||||
|
|
||||||
respRec := httptest.NewRecorder()
|
respRec := httptest.NewRecorder()
|
||||||
req, _ := http.NewRequest("GET", "/non-existent-endpoint.jpg", nil)
|
req, _ := http.NewRequest("GET", "/non-existent-endpoint.jpg", nil)
|
||||||
|
|
||||||
|
@ -8,9 +8,13 @@ import (
|
|||||||
"npm/internal/logger"
|
"npm/internal/logger"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestInit(t *testing.T) {
|
func TestInit(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
t.Setenv("NPM_DATA_FOLDER", "/path/to/some/data/folder")
|
t.Setenv("NPM_DATA_FOLDER", "/path/to/some/data/folder")
|
||||||
t.Setenv("NPM_LOG_LEVEL", "warn")
|
t.Setenv("NPM_LOG_LEVEL", "warn")
|
||||||
t.Setenv("NPM_DB_DRIVER", "postgres")
|
t.Setenv("NPM_DB_DRIVER", "postgres")
|
||||||
@ -45,6 +49,9 @@ func TestInit(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestConnectURLs(t *testing.T) {
|
func TestConnectURLs(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
type want struct {
|
type want struct {
|
||||||
gorm string
|
gorm string
|
||||||
dbmate string
|
dbmate string
|
||||||
@ -118,6 +125,9 @@ func TestConnectURLs(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCreateDataFolders(t *testing.T) {
|
func TestCreateDataFolders(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
t.Setenv("NPM_DATA_FOLDER", "/tmp/npmtest")
|
t.Setenv("NPM_DATA_FOLDER", "/tmp/npmtest")
|
||||||
|
|
||||||
version := "777.777.777"
|
version := "777.777.777"
|
||||||
|
@ -2,8 +2,9 @@ package config
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"npm/internal/logger"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"npm/internal/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CreateDataFolders will recursively create these folders within the
|
// CreateDataFolders will recursively create these folders within the
|
||||||
|
@ -4,9 +4,13 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAcmeshGetWellknown(t *testing.T) {
|
func TestAcmeshGetWellknown(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
a := acmesh{
|
a := acmesh{
|
||||||
Home: "/data/.acme.sh",
|
Home: "/data/.acme.sh",
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,13 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGetAll(t *testing.T) {
|
func TestGetAll(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
providers := GetAll()
|
providers := GetAll()
|
||||||
// This number will have to (annoyingly) be updated
|
// This number will have to (annoyingly) be updated
|
||||||
// when adding new dns providers to the list
|
// when adding new dns providers to the list
|
||||||
@ -23,6 +27,9 @@ func TestGetAll(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGet(t *testing.T) {
|
func TestGet(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
provider, err := Get("dns_duckdns")
|
provider, err := Get("dns_duckdns")
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.Equal(t, "dns_duckdns", provider.Title)
|
assert.Equal(t, "dns_duckdns", provider.Title)
|
||||||
|
@ -5,9 +5,13 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAcmeDNSProvider(t *testing.T) {
|
func TestAcmeDNSProvider(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
provider := getDNSAcmeDNS()
|
provider := getDNSAcmeDNS()
|
||||||
json, err := provider.GetJsonSchema()
|
json, err := provider.GetJsonSchema()
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
@ -5,9 +5,13 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAdProvider(t *testing.T) {
|
func TestAdProvider(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
provider := getDNSAd()
|
provider := getDNSAd()
|
||||||
provider.ConvertToUpdatable()
|
provider.ConvertToUpdatable()
|
||||||
json, err := provider.GetJsonSchema()
|
json, err := provider.GetJsonSchema()
|
||||||
|
@ -5,9 +5,13 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAliProvider(t *testing.T) {
|
func TestAliProvider(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
provider := getDNSAli()
|
provider := getDNSAli()
|
||||||
json, err := provider.GetJsonSchema()
|
json, err := provider.GetJsonSchema()
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
// +------------+
|
// +------------+
|
||||||
@ -62,6 +63,9 @@ func assertModel(t *testing.T, m Model) {
|
|||||||
// +------------+
|
// +------------+
|
||||||
|
|
||||||
func (s *testsuite) TestGetByID() {
|
func (s *testsuite) TestGetByID() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
s.mock.
|
s.mock.
|
||||||
ExpectQuery(regexp.QuoteMeta(`SELECT * FROM "auth" WHERE "auth"."id" = $1 AND "auth"."is_deleted" = $2 ORDER BY "auth"."id" LIMIT 1`)).
|
ExpectQuery(regexp.QuoteMeta(`SELECT * FROM "auth" WHERE "auth"."id" = $1 AND "auth"."is_deleted" = $2 ORDER BY "auth"."id" LIMIT 1`)).
|
||||||
WithArgs(10, 0).
|
WithArgs(10, 0).
|
||||||
@ -74,6 +78,9 @@ func (s *testsuite) TestGetByID() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *testsuite) TestGetByUserIDType() {
|
func (s *testsuite) TestGetByUserIDType() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
s.mock.
|
s.mock.
|
||||||
ExpectQuery(regexp.QuoteMeta(`SELECT * FROM "auth" WHERE user_id = $1 AND type = $2 AND "auth"."is_deleted" = $3 ORDER BY "auth"."id" LIMIT 1`)).
|
ExpectQuery(regexp.QuoteMeta(`SELECT * FROM "auth" WHERE user_id = $1 AND type = $2 AND "auth"."is_deleted" = $3 ORDER BY "auth"."id" LIMIT 1`)).
|
||||||
WithArgs(100, TypePassword, 0).
|
WithArgs(100, TypePassword, 0).
|
||||||
@ -86,6 +93,9 @@ func (s *testsuite) TestGetByUserIDType() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *testsuite) TestSave() {
|
func (s *testsuite) TestSave() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
s.mock.ExpectBegin()
|
s.mock.ExpectBegin()
|
||||||
s.mock.ExpectQuery(regexp.QuoteMeta(`INSERT INTO "auth" ("created_at","updated_at","is_deleted","user_id","type","secret") VALUES ($1,$2,$3,$4,$5,$6) RETURNING "id"`)).
|
s.mock.ExpectQuery(regexp.QuoteMeta(`INSERT INTO "auth" ("created_at","updated_at","is_deleted","user_id","type","secret") VALUES ($1,$2,$3,$4,$5,$6) RETURNING "id"`)).
|
||||||
WithArgs(
|
WithArgs(
|
||||||
@ -111,6 +121,9 @@ func (s *testsuite) TestSave() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *testsuite) TestSetPassword() {
|
func (s *testsuite) TestSetPassword() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
m := Model{UserID: 100}
|
m := Model{UserID: 100}
|
||||||
err := m.SetPassword("abc123")
|
err := m.SetPassword("abc123")
|
||||||
require.NoError(s.T(), err)
|
require.NoError(s.T(), err)
|
||||||
@ -120,6 +133,9 @@ func (s *testsuite) TestSetPassword() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *testsuite) TestValidateSecret() {
|
func (s *testsuite) TestValidateSecret() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
m := Model{UserID: 100}
|
m := Model{UserID: 100}
|
||||||
m.SetPassword("abc123")
|
m.SetPassword("abc123")
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
// +------------+
|
// +------------+
|
||||||
@ -102,6 +103,9 @@ func assertModel(t *testing.T, m Model) {
|
|||||||
// +------------+
|
// +------------+
|
||||||
|
|
||||||
func (s *testsuite) TestGetByID() {
|
func (s *testsuite) TestGetByID() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
s.mock.
|
s.mock.
|
||||||
ExpectQuery(regexp.QuoteMeta(`SELECT * FROM "certificate_authority" WHERE "certificate_authority"."id" = $1 AND "certificate_authority"."is_deleted" = $2 ORDER BY "certificate_authority"."id" LIMIT 1`)).
|
ExpectQuery(regexp.QuoteMeta(`SELECT * FROM "certificate_authority" WHERE "certificate_authority"."id" = $1 AND "certificate_authority"."is_deleted" = $2 ORDER BY "certificate_authority"."id" LIMIT 1`)).
|
||||||
WithArgs(10, 0).
|
WithArgs(10, 0).
|
||||||
@ -114,6 +118,9 @@ func (s *testsuite) TestGetByID() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *testsuite) TestList() {
|
func (s *testsuite) TestList() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
s.mock.
|
s.mock.
|
||||||
ExpectQuery(regexp.QuoteMeta(`SELECT count(*) FROM "certificate_authority" WHERE name LIKE $1 AND "certificate_authority"."is_deleted" = $2`)).
|
ExpectQuery(regexp.QuoteMeta(`SELECT count(*) FROM "certificate_authority" WHERE name LIKE $1 AND "certificate_authority"."is_deleted" = $2`)).
|
||||||
WithArgs("%test%", 0).
|
WithArgs("%test%", 0).
|
||||||
@ -156,6 +163,9 @@ func (s *testsuite) TestList() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *testsuite) TestSave() {
|
func (s *testsuite) TestSave() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
s.mock.ExpectBegin()
|
s.mock.ExpectBegin()
|
||||||
s.mock.ExpectQuery(regexp.QuoteMeta(`INSERT INTO "certificate_authority" ("created_at","updated_at","is_deleted","name","acmesh_server","ca_bundle","max_domains","is_wildcard_supported","is_readonly") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9) RETURNING "id"`)).
|
s.mock.ExpectQuery(regexp.QuoteMeta(`INSERT INTO "certificate_authority" ("created_at","updated_at","is_deleted","name","acmesh_server","ca_bundle","max_domains","is_wildcard_supported","is_readonly") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9) RETURNING "id"`)).
|
||||||
WithArgs(
|
WithArgs(
|
||||||
@ -185,6 +195,9 @@ func (s *testsuite) TestSave() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *testsuite) TestDelete() {
|
func (s *testsuite) TestDelete() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
s.mock.ExpectBegin()
|
s.mock.ExpectBegin()
|
||||||
s.mock.
|
s.mock.
|
||||||
ExpectExec(regexp.QuoteMeta(`UPDATE "certificate_authority" SET "is_deleted"=$1 WHERE "certificate_authority"."id" = $2 AND "certificate_authority"."is_deleted" = $3`)).
|
ExpectExec(regexp.QuoteMeta(`UPDATE "certificate_authority" SET "is_deleted"=$1 WHERE "certificate_authority"."id" = $2 AND "certificate_authority"."is_deleted" = $3`)).
|
||||||
@ -207,6 +220,9 @@ func (s *testsuite) TestDelete() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *testsuite) TestCheck() {
|
func (s *testsuite) TestCheck() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
m := Model{}
|
m := Model{}
|
||||||
err := m.Check()
|
err := m.Check()
|
||||||
assert.Nil(s.T(), err)
|
assert.Nil(s.T(), err)
|
||||||
|
@ -13,6 +13,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
// +------------+
|
// +------------+
|
||||||
@ -108,6 +109,9 @@ func assertModel(t *testing.T, m Model) {
|
|||||||
// +------------+
|
// +------------+
|
||||||
|
|
||||||
func (s *testsuite) TestGetByID() {
|
func (s *testsuite) TestGetByID() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
s.mock.
|
s.mock.
|
||||||
ExpectQuery(regexp.QuoteMeta(`SELECT * FROM "dns_provider" WHERE "dns_provider"."id" = $1 AND "dns_provider"."is_deleted" = $2 ORDER BY "dns_provider"."id" LIMIT 1`)).
|
ExpectQuery(regexp.QuoteMeta(`SELECT * FROM "dns_provider" WHERE "dns_provider"."id" = $1 AND "dns_provider"."is_deleted" = $2 ORDER BY "dns_provider"."id" LIMIT 1`)).
|
||||||
WithArgs(10, 0).
|
WithArgs(10, 0).
|
||||||
@ -120,6 +124,9 @@ func (s *testsuite) TestGetByID() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *testsuite) TestGetAcmeShEnvVars() {
|
func (s *testsuite) TestGetAcmeShEnvVars() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
type want struct {
|
type want struct {
|
||||||
envs []string
|
envs []string
|
||||||
err error
|
err error
|
||||||
@ -193,6 +200,9 @@ func (s *testsuite) TestGetAcmeShEnvVars() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *testsuite) TestList() {
|
func (s *testsuite) TestList() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
s.mock.
|
s.mock.
|
||||||
ExpectQuery(regexp.QuoteMeta(`SELECT count(*) FROM "dns_provider" WHERE acmesh_name LIKE $1 AND "dns_provider"."is_deleted" = $2`)).
|
ExpectQuery(regexp.QuoteMeta(`SELECT count(*) FROM "dns_provider" WHERE acmesh_name LIKE $1 AND "dns_provider"."is_deleted" = $2`)).
|
||||||
WithArgs("dns%", 0).
|
WithArgs("dns%", 0).
|
||||||
@ -235,6 +245,9 @@ func (s *testsuite) TestList() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *testsuite) TestSave() {
|
func (s *testsuite) TestSave() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
s.mock.ExpectBegin()
|
s.mock.ExpectBegin()
|
||||||
s.mock.ExpectQuery(regexp.QuoteMeta(`INSERT INTO "dns_provider" ("created_at","updated_at","is_deleted","user_id","name","acmesh_name","dns_sleep","meta") VALUES ($1,$2,$3,$4,$5,$6,$7,$8) RETURNING "id"`)).
|
s.mock.ExpectQuery(regexp.QuoteMeta(`INSERT INTO "dns_provider" ("created_at","updated_at","is_deleted","user_id","name","acmesh_name","dns_sleep","meta") VALUES ($1,$2,$3,$4,$5,$6,$7,$8) RETURNING "id"`)).
|
||||||
WithArgs(
|
WithArgs(
|
||||||
@ -268,6 +281,9 @@ func (s *testsuite) TestSave() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *testsuite) TestDelete() {
|
func (s *testsuite) TestDelete() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
s.mock.ExpectBegin()
|
s.mock.ExpectBegin()
|
||||||
s.mock.
|
s.mock.
|
||||||
ExpectExec(regexp.QuoteMeta(`UPDATE "dns_provider" SET "is_deleted"=$1 WHERE "dns_provider"."id" = $2 AND "dns_provider"."is_deleted" = $3`)).
|
ExpectExec(regexp.QuoteMeta(`UPDATE "dns_provider" SET "is_deleted"=$1 WHERE "dns_provider"."id" = $2 AND "dns_provider"."is_deleted" = $3`)).
|
||||||
|
@ -14,6 +14,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
// +------------+
|
// +------------+
|
||||||
@ -105,6 +106,9 @@ func TestExampleTestSuite(t *testing.T) {
|
|||||||
// +------------+
|
// +------------+
|
||||||
|
|
||||||
func (s *testsuite) TestGetByID() {
|
func (s *testsuite) TestGetByID() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
s.mock.
|
s.mock.
|
||||||
ExpectQuery(regexp.QuoteMeta(`SELECT * FROM "host" WHERE "host"."id" = $1 AND "host"."is_deleted" = $2 ORDER BY "host"."id" LIMIT 1`)).
|
ExpectQuery(regexp.QuoteMeta(`SELECT * FROM "host" WHERE "host"."id" = $1 AND "host"."is_deleted" = $2 ORDER BY "host"."id" LIMIT 1`)).
|
||||||
WithArgs(10, 0).
|
WithArgs(10, 0).
|
||||||
@ -117,6 +121,9 @@ func (s *testsuite) TestGetByID() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *testsuite) TestSave() {
|
func (s *testsuite) TestSave() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
s.mock.ExpectBegin()
|
s.mock.ExpectBegin()
|
||||||
s.mock.ExpectQuery(regexp.QuoteMeta(`INSERT INTO "host" ("created_at","updated_at","is_deleted","user_id","type","nginx_template_id","listen_interface","domain_names","upstream_id","proxy_scheme","proxy_host","proxy_port","certificate_id","access_list_id","ssl_forced","caching_enabled","block_exploits","allow_websocket_upgrade","http2_support","hsts_enabled","hsts_subdomains","paths","advanced_config","status","error_message","is_disabled") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26) RETURNING "id"`)).
|
s.mock.ExpectQuery(regexp.QuoteMeta(`INSERT INTO "host" ("created_at","updated_at","is_deleted","user_id","type","nginx_template_id","listen_interface","domain_names","upstream_id","proxy_scheme","proxy_host","proxy_port","certificate_id","access_list_id","ssl_forced","caching_enabled","block_exploits","allow_websocket_upgrade","http2_support","hsts_enabled","hsts_subdomains","paths","advanced_config","status","error_message","is_disabled") VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24,$25,$26) RETURNING "id"`)).
|
||||||
WithArgs(
|
WithArgs(
|
||||||
@ -167,6 +174,9 @@ func (s *testsuite) TestSave() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *testsuite) TestDelete() {
|
func (s *testsuite) TestDelete() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
s.mock.ExpectBegin()
|
s.mock.ExpectBegin()
|
||||||
s.mock.
|
s.mock.
|
||||||
ExpectExec(regexp.QuoteMeta(`UPDATE "host" SET "is_deleted"=$1 WHERE "host"."id" = $2 AND "host"."is_deleted" = $3`)).
|
ExpectExec(regexp.QuoteMeta(`UPDATE "host" SET "is_deleted"=$1 WHERE "host"."id" = $2 AND "host"."is_deleted" = $3`)).
|
||||||
@ -189,6 +199,9 @@ func (s *testsuite) TestDelete() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *testsuite) TestGetTemplate() {
|
func (s *testsuite) TestGetTemplate() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
m := Model{
|
m := Model{
|
||||||
ModelBase: model.ModelBase{
|
ModelBase: model.ModelBase{
|
||||||
ID: 10,
|
ID: 10,
|
||||||
|
@ -13,6 +13,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
// +------------+
|
// +------------+
|
||||||
@ -114,6 +115,9 @@ func assertModel(t *testing.T, m Model) {
|
|||||||
// +------------+
|
// +------------+
|
||||||
|
|
||||||
func (s *testsuite) TestGetByID() {
|
func (s *testsuite) TestGetByID() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
s.mock.
|
s.mock.
|
||||||
ExpectQuery(regexp.QuoteMeta(`SELECT * FROM "user" WHERE "user"."id" = $1 AND "user"."is_deleted" = $2 ORDER BY "user"."id" LIMIT 1`)).
|
ExpectQuery(regexp.QuoteMeta(`SELECT * FROM "user" WHERE "user"."id" = $1 AND "user"."is_deleted" = $2 ORDER BY "user"."id" LIMIT 1`)).
|
||||||
WithArgs(10, 0).
|
WithArgs(10, 0).
|
||||||
@ -126,6 +130,9 @@ func (s *testsuite) TestGetByID() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *testsuite) TestLoadByEmail() {
|
func (s *testsuite) TestLoadByEmail() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
s.mock.
|
s.mock.
|
||||||
ExpectQuery(regexp.QuoteMeta(`SELECT * FROM "user" WHERE email = $1 AND is_system = $2 AND "user"."is_deleted" = $3 ORDER BY "user"."id" LIMIT 1`)).
|
ExpectQuery(regexp.QuoteMeta(`SELECT * FROM "user" WHERE email = $1 AND is_system = $2 AND "user"."is_deleted" = $3 ORDER BY "user"."id" LIMIT 1`)).
|
||||||
WithArgs("jon@example.com", false, 0).
|
WithArgs("jon@example.com", false, 0).
|
||||||
@ -138,6 +145,9 @@ func (s *testsuite) TestLoadByEmail() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *testsuite) TestIsEnabled() {
|
func (s *testsuite) TestIsEnabled() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
s.mock.
|
s.mock.
|
||||||
ExpectQuery(regexp.QuoteMeta(`SELECT * FROM "user" WHERE "user"."id" = $1 AND "user"."is_deleted" = $2 ORDER BY "user"."id" LIMIT 1`)).
|
ExpectQuery(regexp.QuoteMeta(`SELECT * FROM "user" WHERE "user"."id" = $1 AND "user"."is_deleted" = $2 ORDER BY "user"."id" LIMIT 1`)).
|
||||||
WithArgs(10, 0).
|
WithArgs(10, 0).
|
||||||
@ -163,6 +173,9 @@ func (s *testsuite) TestIsEnabled() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *testsuite) TestSave() {
|
func (s *testsuite) TestSave() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
s.mock.
|
s.mock.
|
||||||
ExpectQuery(regexp.QuoteMeta(`SELECT * FROM "user" WHERE email = $1 AND is_system = $2 AND "user"."is_deleted" = $3 ORDER BY "user"."id" LIMIT 1`)).
|
ExpectQuery(regexp.QuoteMeta(`SELECT * FROM "user" WHERE email = $1 AND is_system = $2 AND "user"."is_deleted" = $3 ORDER BY "user"."id" LIMIT 1`)).
|
||||||
WithArgs("jon@example.com", false, 0).
|
WithArgs("jon@example.com", false, 0).
|
||||||
@ -206,6 +219,9 @@ func (s *testsuite) TestSave() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *testsuite) TestDelete() {
|
func (s *testsuite) TestDelete() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
s.mock.ExpectBegin()
|
s.mock.ExpectBegin()
|
||||||
s.mock.
|
s.mock.
|
||||||
ExpectExec(regexp.QuoteMeta(`UPDATE "user" SET "is_deleted"=$1 WHERE "user"."id" = $2 AND "user"."is_deleted" = $3`)).
|
ExpectExec(regexp.QuoteMeta(`UPDATE "user" SET "is_deleted"=$1 WHERE "user"."id" = $2 AND "user"."is_deleted" = $3`)).
|
||||||
@ -229,12 +245,18 @@ func (s *testsuite) TestDelete() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *testsuite) TestGenerateGravatar() {
|
func (s *testsuite) TestGenerateGravatar() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
m := Model{Email: "jon@example.com"}
|
m := Model{Email: "jon@example.com"}
|
||||||
m.generateGravatar()
|
m.generateGravatar()
|
||||||
assert.Equal(s.T(), "https://www.gravatar.com/avatar/dc36565cc2376197358fa27ed4c47253?d=mm&r=pg&s=128", m.GravatarURL)
|
assert.Equal(s.T(), "https://www.gravatar.com/avatar/dc36565cc2376197358fa27ed4c47253?d=mm&r=pg&s=128", m.GravatarURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *testsuite) TestDeleteAll() {
|
func (s *testsuite) TestDeleteAll() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
s.mock.
|
s.mock.
|
||||||
ExpectExec(regexp.QuoteMeta("DELETE FROM `user` WHERE is_system = $1")).
|
ExpectExec(regexp.QuoteMeta("DELETE FROM `user` WHERE is_system = $1")).
|
||||||
WithArgs(false).
|
WithArgs(false).
|
||||||
@ -246,6 +268,9 @@ func (s *testsuite) TestDeleteAll() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *testsuite) TestGetCapabilities() {
|
func (s *testsuite) TestGetCapabilities() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
s.mock.
|
s.mock.
|
||||||
ExpectQuery(regexp.QuoteMeta(`SELECT * FROM "user_has_capability" WHERE user_id = $1`)).
|
ExpectQuery(regexp.QuoteMeta(`SELECT * FROM "user_has_capability" WHERE user_id = $1`)).
|
||||||
WithArgs(10).
|
WithArgs(10).
|
||||||
@ -278,6 +303,9 @@ func (s *testsuite) TestGetCapabilities() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *testsuite) TestList() {
|
func (s *testsuite) TestList() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
s.mock.
|
s.mock.
|
||||||
ExpectQuery(regexp.QuoteMeta(`SELECT count(*) FROM "user" WHERE name LIKE $1 AND "user"."is_deleted" = $2`)).
|
ExpectQuery(regexp.QuoteMeta(`SELECT count(*) FROM "user" WHERE name LIKE $1 AND "user"."is_deleted" = $2`)).
|
||||||
WithArgs("%jon%", 0).
|
WithArgs("%jon%", 0).
|
||||||
@ -332,6 +360,9 @@ func (s *testsuite) TestList() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *testsuite) TestSetPermissions() {
|
func (s *testsuite) TestSetPermissions() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
s.mock.ExpectBegin()
|
s.mock.ExpectBegin()
|
||||||
s.mock.
|
s.mock.
|
||||||
ExpectExec(regexp.QuoteMeta(`DELETE FROM "user_has_capability" WHERE user_id = $1`)).
|
ExpectExec(regexp.QuoteMeta(`DELETE FROM "user_has_capability" WHERE user_id = $1`)).
|
||||||
@ -360,6 +391,9 @@ func (s *testsuite) TestSetPermissions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *testsuite) TestSaveCapabilities() {
|
func (s *testsuite) TestSaveCapabilities() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
s.mock.
|
s.mock.
|
||||||
ExpectQuery(regexp.QuoteMeta(`SELECT * FROM "capability"`)).
|
ExpectQuery(regexp.QuoteMeta(`SELECT * FROM "capability"`)).
|
||||||
WillReturnRows(sqlmock.NewRows([]string{"name"}).
|
WillReturnRows(sqlmock.NewRows([]string{"name"}).
|
||||||
@ -400,6 +434,9 @@ func (s *testsuite) TestSaveCapabilities() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *testsuite) TestSaveCapabilitiesInvalid() {
|
func (s *testsuite) TestSaveCapabilitiesInvalid() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
s.mock.
|
s.mock.
|
||||||
ExpectQuery(regexp.QuoteMeta(`SELECT * FROM "capability"`)).
|
ExpectQuery(regexp.QuoteMeta(`SELECT * FROM "capability"`)).
|
||||||
WillReturnRows(sqlmock.NewRows([]string{"name"}).
|
WillReturnRows(sqlmock.NewRows([]string{"name"}).
|
||||||
|
@ -13,6 +13,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
// +------------+
|
// +------------+
|
||||||
@ -123,6 +124,9 @@ func TestExampleTestSuite(t *testing.T) {
|
|||||||
// +------------+
|
// +------------+
|
||||||
|
|
||||||
func (s *testsuite) TestLoadKeys() {
|
func (s *testsuite) TestLoadKeys() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
// Required for clean test runs
|
// Required for clean test runs
|
||||||
currentKeys = KeysModel{}
|
currentKeys = KeysModel{}
|
||||||
|
|
||||||
@ -164,6 +168,9 @@ func (s *testsuite) TestLoadKeys() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *testsuite) TestGetPrivateKey() {
|
func (s *testsuite) TestGetPrivateKey() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
// Required for clean test runs
|
// Required for clean test runs
|
||||||
privateKey = nil
|
privateKey = nil
|
||||||
currentKeys = KeysModel{}
|
currentKeys = KeysModel{}
|
||||||
@ -188,6 +195,9 @@ func (s *testsuite) TestGetPrivateKey() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *testsuite) TestGetPublicKey() {
|
func (s *testsuite) TestGetPublicKey() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
// Required for clean test runs
|
// Required for clean test runs
|
||||||
publicKey = nil
|
publicKey = nil
|
||||||
currentKeys = KeysModel{}
|
currentKeys = KeysModel{}
|
||||||
@ -212,6 +222,9 @@ func (s *testsuite) TestGetPublicKey() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *testsuite) TestGenerate() {
|
func (s *testsuite) TestGenerate() {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(s.T(), goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
currentKeys = KeysModel{
|
currentKeys = KeysModel{
|
||||||
ModelBase: model.ModelBase{
|
ModelBase: model.ModelBase{
|
||||||
ID: 10,
|
ID: 10,
|
||||||
|
@ -9,13 +9,20 @@ import (
|
|||||||
|
|
||||||
"github.com/rotisserie/eris"
|
"github.com/rotisserie/eris"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGetLogLevel(t *testing.T) {
|
func TestGetLogLevel(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
assert.Equal(t, InfoLevel, GetLogLevel())
|
assert.Equal(t, InfoLevel, GetLogLevel())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestThreshold(t *testing.T) {
|
func TestThreshold(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
log.SetOutput(buf)
|
log.SetOutput(buf)
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -37,6 +44,9 @@ func TestThreshold(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDebug(t *testing.T) {
|
func TestDebug(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
log.SetOutput(buf)
|
log.SetOutput(buf)
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -55,6 +65,9 @@ func TestDebug(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestInfo(t *testing.T) {
|
func TestInfo(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
log.SetOutput(buf)
|
log.SetOutput(buf)
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -71,6 +84,9 @@ func TestInfo(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestWarn(t *testing.T) {
|
func TestWarn(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
log.SetOutput(buf)
|
log.SetOutput(buf)
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -87,6 +103,9 @@ func TestWarn(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestError(t *testing.T) {
|
func TestError(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
log.SetOutput(buf)
|
log.SetOutput(buf)
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -103,6 +122,9 @@ func TestError(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestConfigure(t *testing.T) {
|
func TestConfigure(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
type args struct {
|
type args struct {
|
||||||
c *Config
|
c *Config
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,13 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPageInfoGetSort(t *testing.T) {
|
func TestPageInfoGetSort(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("testing.tRunner.func1"))
|
||||||
|
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
pi := PageInfo{}
|
pi := PageInfo{}
|
||||||
def := Sort{
|
def := Sort{
|
||||||
|
@ -7,9 +7,13 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGetHostFilename(t *testing.T) {
|
func TestGetHostFilename(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
test.InitConfig(t)
|
test.InitConfig(t)
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
|
@ -10,9 +10,13 @@ import (
|
|||||||
"npm/internal/types"
|
"npm/internal/types"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestRenderTemplate(t *testing.T) {
|
func TestRenderTemplate(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
test.InitConfig(t)
|
test.InitConfig(t)
|
||||||
|
|
||||||
template := `
|
template := `
|
||||||
|
@ -4,15 +4,22 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGet(t *testing.T) {
|
func TestGet(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("github.com/jc21/go-sse.(*Server).dispatch"))
|
||||||
|
|
||||||
s := Get()
|
s := Get()
|
||||||
assert.NotEqual(t, nil, s)
|
assert.NotEqual(t, nil, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is just for code coverage more than anything
|
// This is just for code coverage more than anything
|
||||||
func TestEverything(t *testing.T) {
|
func TestEverything(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t)
|
||||||
|
|
||||||
Get()
|
Get()
|
||||||
SendMessage("test", "test", map[string]string{"user_id": "10"})
|
SendMessage("test", "test", map[string]string{"user_id": "10"})
|
||||||
SendChange("hosts")
|
SendChange("hosts")
|
||||||
|
@ -1,14 +1,19 @@
|
|||||||
package tags
|
package tags
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"npm/internal/util"
|
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"npm/internal/util"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGetFilterSchema(t *testing.T) {
|
func TestGetFilterSchema(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
type testDemo struct {
|
type testDemo struct {
|
||||||
ID uint `json:"id" gorm:"column:user_id" filter:"id,number"`
|
ID uint `json:"id" gorm:"column:user_id" filter:"id,number"`
|
||||||
Created time.Time `json:"created" gorm:"column:user_created_date" filter:"created,date"`
|
Created time.Time `json:"created" gorm:"column:user_created_date" filter:"created,date"`
|
||||||
@ -28,6 +33,9 @@ func TestGetFilterSchema(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetFilterTagSchema(t *testing.T) {
|
func TestGetFilterTagSchema(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
schema := util.PrettyPrintJSON(getFilterTagSchema("id,integer"))
|
schema := util.PrettyPrintJSON(getFilterTagSchema("id,integer"))
|
||||||
|
|
||||||
expectedSchema := `{
|
expectedSchema := `{
|
||||||
@ -63,6 +71,9 @@ func TestGetFilterTagSchema(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestBoolFieldSchema(t *testing.T) {
|
func TestBoolFieldSchema(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
schema := util.PrettyPrintJSON(boolFieldSchema("active"))
|
schema := util.PrettyPrintJSON(boolFieldSchema("active"))
|
||||||
|
|
||||||
expectedSchema := `{
|
expectedSchema := `{
|
||||||
|
@ -1,13 +1,18 @@
|
|||||||
package tags
|
package tags
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"npm/internal/model"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"npm/internal/model"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestGetName(t *testing.T) {
|
func TestGetName(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
type testDemo struct {
|
type testDemo struct {
|
||||||
UserID uint `json:"user_id" gorm:"column:user_id" filter:"user_id,integer"`
|
UserID uint `json:"user_id" gorm:"column:user_id" filter:"user_id,integer"`
|
||||||
Type string `json:"type" gorm:"column:type" filter:"type,string"`
|
Type string `json:"type" gorm:"column:type" filter:"type,string"`
|
||||||
@ -18,6 +23,9 @@ func TestGetName(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCache(t *testing.T) {
|
func TestCache(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
name := "testdemo"
|
name := "testdemo"
|
||||||
// Should return error
|
// Should return error
|
||||||
_, exists := getCache(name)
|
_, exists := getCache(name)
|
||||||
|
@ -4,9 +4,14 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDBDate_Value(t *testing.T) {
|
func TestDBDate_Value(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
// Create a DBDate instance with a specific time
|
// Create a DBDate instance with a specific time
|
||||||
expectedTime := time.Date(2022, time.January, 1, 0, 0, 0, 0, time.UTC)
|
expectedTime := time.Date(2022, time.January, 1, 0, 0, 0, 0, time.UTC)
|
||||||
dbDate := DBDate{Time: expectedTime}
|
dbDate := DBDate{Time: expectedTime}
|
||||||
@ -32,6 +37,9 @@ func TestDBDate_Value(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDBDate_Scan(t *testing.T) {
|
func TestDBDate_Scan(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
// Simulate a value from the database (unix timestamp)
|
// Simulate a value from the database (unix timestamp)
|
||||||
unixTime := int64(1640995200)
|
unixTime := int64(1640995200)
|
||||||
|
|
||||||
@ -56,6 +64,9 @@ func TestDBDate_Scan(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDBDate_UnmarshalJSON(t *testing.T) {
|
func TestDBDate_UnmarshalJSON(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
// Simulate a JSON input representing a unix timestamp
|
// Simulate a JSON input representing a unix timestamp
|
||||||
jsonData := []byte("1640995200")
|
jsonData := []byte("1640995200")
|
||||||
|
|
||||||
@ -81,6 +92,9 @@ func TestDBDate_UnmarshalJSON(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDBDate_MarshalJSON(t *testing.T) {
|
func TestDBDate_MarshalJSON(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
// Create a DBDate instance with a specific time
|
// Create a DBDate instance with a specific time
|
||||||
expectedTime := time.Date(2022, time.January, 1, 0, 0, 0, 0, time.UTC)
|
expectedTime := time.Date(2022, time.January, 1, 0, 0, 0, 0, time.UTC)
|
||||||
dbDate := DBDate{Time: expectedTime}
|
dbDate := DBDate{Time: expectedTime}
|
||||||
|
@ -2,9 +2,14 @@ package types
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNullableDBIntValue(t *testing.T) {
|
func TestNullableDBIntValue(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
var d NullableDBInt
|
var d NullableDBInt
|
||||||
|
|
||||||
// Test when Int is 0 (null)
|
// Test when Int is 0 (null)
|
||||||
@ -23,6 +28,9 @@ func TestNullableDBIntValue(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestNullableDBIntScan(t *testing.T) {
|
func TestNullableDBIntScan(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
var d NullableDBInt
|
var d NullableDBInt
|
||||||
|
|
||||||
// Test when src is an int
|
// Test when src is an int
|
||||||
@ -57,6 +65,9 @@ func TestNullableDBIntScan(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestNullableDBIntUnmarshalJSON(t *testing.T) {
|
func TestNullableDBIntUnmarshalJSON(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
var d NullableDBInt
|
var d NullableDBInt
|
||||||
|
|
||||||
// Test when data is an integer value
|
// Test when data is an integer value
|
||||||
@ -73,6 +84,9 @@ func TestNullableDBIntUnmarshalJSON(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestNullableDBIntMarshalJSON(t *testing.T) {
|
func TestNullableDBIntMarshalJSON(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
var d NullableDBInt
|
var d NullableDBInt
|
||||||
|
|
||||||
// Test when Int is 0 (null)
|
// Test when Int is 0 (null)
|
||||||
|
@ -3,9 +3,14 @@ package types
|
|||||||
import (
|
import (
|
||||||
"database/sql/driver"
|
"database/sql/driver"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNullableDBUint_Value(t *testing.T) {
|
func TestNullableDBUint_Value(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
input NullableDBUint
|
input NullableDBUint
|
||||||
@ -40,6 +45,9 @@ func TestNullableDBUint_Value(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestNullableDBUint_Scan(t *testing.T) {
|
func TestNullableDBUint_Scan(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
input interface{}
|
input interface{}
|
||||||
@ -76,6 +84,9 @@ func TestNullableDBUint_Scan(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestNullableDBUint_UnmarshalJSON(t *testing.T) {
|
func TestNullableDBUint_UnmarshalJSON(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
input []byte
|
input []byte
|
||||||
@ -112,6 +123,9 @@ func TestNullableDBUint_UnmarshalJSON(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestNullableDBUint_MarshalJSON(t *testing.T) {
|
func TestNullableDBUint_MarshalJSON(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
input NullableDBUint
|
input NullableDBUint
|
||||||
|
@ -3,10 +3,15 @@ package types
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestNullableDBDateValue tests the Value method of the NullableDBDate type
|
// TestNullableDBDateValue tests the Value method of the NullableDBDate type
|
||||||
func TestNullableDBDateValue(t *testing.T) {
|
func TestNullableDBDateValue(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
tme := time.Date(2022, time.January, 1, 0, 0, 0, 0, time.UTC)
|
tme := time.Date(2022, time.January, 1, 0, 0, 0, 0, time.UTC)
|
||||||
d := NullableDBDate{
|
d := NullableDBDate{
|
||||||
Time: &tme,
|
Time: &tme,
|
||||||
@ -26,6 +31,9 @@ func TestNullableDBDateValue(t *testing.T) {
|
|||||||
|
|
||||||
// TestNullableDBDateScan tests the Scan method of the NullableDBDate type
|
// TestNullableDBDateScan tests the Scan method of the NullableDBDate type
|
||||||
func TestNullableDBDateScan(t *testing.T) {
|
func TestNullableDBDateScan(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
var d NullableDBDate
|
var d NullableDBDate
|
||||||
|
|
||||||
err := d.Scan(int64(1640995200))
|
err := d.Scan(int64(1640995200))
|
||||||
@ -42,6 +50,9 @@ func TestNullableDBDateScan(t *testing.T) {
|
|||||||
|
|
||||||
// TestNullableDBDateUnmarshalJSON tests the UnmarshalJSON method of the NullableDBDate type
|
// TestNullableDBDateUnmarshalJSON tests the UnmarshalJSON method of the NullableDBDate type
|
||||||
func TestNullableDBDateUnmarshalJSON(t *testing.T) {
|
func TestNullableDBDateUnmarshalJSON(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
data := []byte(`1640995200`)
|
data := []byte(`1640995200`)
|
||||||
var d NullableDBDate
|
var d NullableDBDate
|
||||||
|
|
||||||
@ -59,6 +70,9 @@ func TestNullableDBDateUnmarshalJSON(t *testing.T) {
|
|||||||
|
|
||||||
// TestNullableDBDateMarshalJSON tests the MarshalJSON method of the NullableDBDate type
|
// TestNullableDBDateMarshalJSON tests the MarshalJSON method of the NullableDBDate type
|
||||||
func TestNullableDBDateMarshalJSON(t *testing.T) {
|
func TestNullableDBDateMarshalJSON(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
tme := time.Date(2022, time.January, 1, 0, 0, 0, 0, time.UTC)
|
tme := time.Date(2022, time.January, 1, 0, 0, 0, 0, time.UTC)
|
||||||
d := NullableDBDate{
|
d := NullableDBDate{
|
||||||
Time: &tme,
|
Time: &tme,
|
||||||
@ -78,6 +92,9 @@ func TestNullableDBDateMarshalJSON(t *testing.T) {
|
|||||||
|
|
||||||
// TestNullableDBDateAsInt64 tests the AsInt64 method of the NullableDBDate type
|
// TestNullableDBDateAsInt64 tests the AsInt64 method of the NullableDBDate type
|
||||||
func TestNullableDBDateAsInt64(t *testing.T) {
|
func TestNullableDBDateAsInt64(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
tme := time.Date(2022, time.January, 1, 0, 0, 0, 0, time.UTC)
|
tme := time.Date(2022, time.January, 1, 0, 0, 0, 0, time.UTC)
|
||||||
d := NullableDBDate{
|
d := NullableDBDate{
|
||||||
Time: &tme,
|
Time: &tme,
|
||||||
@ -93,6 +110,9 @@ func TestNullableDBDateAsInt64(t *testing.T) {
|
|||||||
|
|
||||||
// TestNullableDBDateAsString tests the AsString method of the NullableDBDate type
|
// TestNullableDBDateAsString tests the AsString method of the NullableDBDate type
|
||||||
func TestNullableDBDateAsString(t *testing.T) {
|
func TestNullableDBDateAsString(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
tme := time.Date(2022, time.January, 1, 0, 0, 0, 0, time.UTC)
|
tme := time.Date(2022, time.January, 1, 0, 0, 0, 0, time.UTC)
|
||||||
d := NullableDBDate{
|
d := NullableDBDate{
|
||||||
Time: &tme,
|
Time: &tme,
|
||||||
|
@ -4,9 +4,13 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestFindItemInInterface(t *testing.T) {
|
func TestFindItemInInterface(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
obj := map[string]interface{}{
|
obj := map[string]interface{}{
|
||||||
"key1": "value1",
|
"key1": "value1",
|
||||||
"key2": 10,
|
"key2": 10,
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
type rect struct {
|
type rect struct {
|
||||||
@ -12,6 +13,9 @@ type rect struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMapContainsKey(t *testing.T) {
|
func TestMapContainsKey(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
var r rect
|
var r rect
|
||||||
r.width = 5
|
r.width = 5
|
||||||
r.height = 5
|
r.height = 5
|
||||||
|
@ -5,9 +5,13 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSliceContainsItem(t *testing.T) {
|
func TestSliceContainsItem(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
type want struct {
|
type want struct {
|
||||||
result bool
|
result bool
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,13 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCleanupWhitespace(t *testing.T) {
|
func TestCleanupWhitespace(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
input string
|
input string
|
||||||
@ -51,6 +55,9 @@ upstream npm_upstream_5 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestPrettyPrintJSON(t *testing.T) {
|
func TestPrettyPrintJSON(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
input string
|
input string
|
||||||
expected string
|
expected string
|
||||||
|
@ -4,9 +4,13 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"go.uber.org/goleak"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestUnixMilliToNiceFormat(t *testing.T) {
|
func TestUnixMilliToNiceFormat(t *testing.T) {
|
||||||
|
// goleak is used to detect goroutine leaks
|
||||||
|
defer goleak.VerifyNone(t, goleak.IgnoreAnyFunction("database/sql.(*DB).connectionOpener"))
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
input int64
|
input int64
|
||||||
expected string
|
expected string
|
||||||
|
@ -2,7 +2,6 @@ import { useEffect, useReducer, useState } from "react";
|
|||||||
|
|
||||||
import { Alert, AlertIcon, useToast } from "@chakra-ui/react";
|
import { Alert, AlertIcon, useToast } from "@chakra-ui/react";
|
||||||
import { useQueryClient } from "@tanstack/react-query";
|
import { useQueryClient } from "@tanstack/react-query";
|
||||||
|
|
||||||
import { renewCertificate } from "src/api/npm";
|
import { renewCertificate } from "src/api/npm";
|
||||||
import { EmptyList, SpinnerPage, tableEventReducer } from "src/components";
|
import { EmptyList, SpinnerPage, tableEventReducer } from "src/components";
|
||||||
import { useCertificates } from "src/hooks";
|
import { useCertificates } from "src/hooks";
|
||||||
@ -81,10 +80,6 @@ function TableWrapper() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFetching || isLoading || !tableData) {
|
|
||||||
return <SpinnerPage />;
|
|
||||||
}
|
|
||||||
|
|
||||||
// When there are no items and no filters active, show the nicer empty view
|
// When there are no items and no filters active, show the nicer empty view
|
||||||
if (data?.total === 0 && filters?.length === 0) {
|
if (data?.total === 0 && filters?.length === 0) {
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user