Run unused against codebase (#12968)
* Remove unused methods * Fix missed issues
Этот коммит содержится в:
коммит произвёл
Jesús Espino
родитель
63a28700f5
Коммит
a2adf7b3f5
@@ -108,7 +108,7 @@ func TestGetJobs(t *testing.T) {
|
||||
received, resp = th.SystemAdminClient.GetJobs(1, 2)
|
||||
require.Nil(t, resp.Error)
|
||||
|
||||
require.Equal(t,jobs[1].Id, received[0].Id, "should've received oldest job last")
|
||||
require.Equal(t, jobs[1].Id, received[0].Id, "should've received oldest job last")
|
||||
|
||||
_, resp = th.Client.GetJobs(0, 60)
|
||||
CheckForbiddenStatus(t, resp)
|
||||
|
||||
@@ -21,8 +21,3 @@ func UnmarshalConfig(r io.Reader, allowEnvironmentOverrides bool) (*model.Config
|
||||
func InitializeConfigurationsTable(db *sqlx.DB) error {
|
||||
return initializeConfigurationsTable(db)
|
||||
}
|
||||
|
||||
// ResolveConfigFilePath exposes the internal resolveConfigFilePath to test only.
|
||||
func ResolveConfigFilePath(path string) (string, error) {
|
||||
return resolveConfigFilePath(path)
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
func stringify(objects []interface{}) []string {
|
||||
stringified := make([]string, len(objects), len(objects))
|
||||
stringified := make([]string, len(objects))
|
||||
for i, object := range objects {
|
||||
stringified[i] = fmt.Sprintf("%+v", object)
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ func TestStringify(t *testing.T) {
|
||||
assert.Empty(t, strings)
|
||||
})
|
||||
t.Run("EmptyShouldReturnEmpty", func(t *testing.T) {
|
||||
strings := stringify(make([]interface{}, 0, 0))
|
||||
strings := stringify(make([]interface{}, 0))
|
||||
assert.Empty(t, strings)
|
||||
})
|
||||
t.Run("PrimitivesAndCompositesShouldReturnCorrectValues", func(t *testing.T) {
|
||||
@@ -83,7 +83,7 @@ func TestToObjects(t *testing.T) {
|
||||
assert.Nil(t, objects)
|
||||
})
|
||||
t.Run("EmptyShouldReturnEmpty", func(t *testing.T) {
|
||||
objects := toObjects(make([]string, 0, 0))
|
||||
objects := toObjects(make([]string, 0))
|
||||
assert.Empty(t, objects)
|
||||
})
|
||||
t.Run("ShouldReturnSliceOfObjects", func(t *testing.T) {
|
||||
|
||||
@@ -9,12 +9,3 @@ const (
|
||||
LSH_NO_CACHE LayeredStoreHint = iota
|
||||
LSH_MASTER_ONLY
|
||||
)
|
||||
|
||||
func hintsContains(hints []LayeredStoreHint, contains LayeredStoreHint) bool {
|
||||
for _, hint := range hints {
|
||||
if hint == contains {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -49,30 +49,6 @@ func (s *LocalCacheSupplier) Next() LayeredStoreSupplier {
|
||||
return s.next
|
||||
}
|
||||
|
||||
func (s *LocalCacheSupplier) doStandardReadCache(ctx context.Context, cache ObjectCache, key string, hints ...LayeredStoreHint) *LayeredStoreSupplierResult {
|
||||
if hintsContains(hints, LSH_NO_CACHE) {
|
||||
if s.metrics != nil {
|
||||
s.metrics.IncrementMemCacheMissCounter(cache.Name())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
if cacheItem, ok := cache.Get(key); ok {
|
||||
if s.metrics != nil {
|
||||
s.metrics.IncrementMemCacheHitCounter(cache.Name())
|
||||
}
|
||||
result := NewSupplierResult()
|
||||
result.Data = cacheItem
|
||||
return result
|
||||
}
|
||||
|
||||
if s.metrics != nil {
|
||||
s.metrics.IncrementMemCacheMissCounter(cache.Name())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *LocalCacheSupplier) doStandardAddToCache(ctx context.Context, cache ObjectCache, key string, result *LayeredStoreSupplierResult, hints ...LayeredStoreHint) {
|
||||
if result.Err == nil && result.Data != nil {
|
||||
cache.AddWithDefaultExpires(key, result.Data)
|
||||
|
||||
@@ -35,19 +35,6 @@ func StoreTest(t *testing.T, f func(*testing.T, store.Store)) {
|
||||
}
|
||||
}
|
||||
|
||||
func StoreTestWithSqlSupplier(t *testing.T, f func(*testing.T, store.Store, storetest.SqlSupplier)) {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
tearDownStores()
|
||||
panic(err)
|
||||
}
|
||||
}()
|
||||
for _, st := range storeTypes {
|
||||
st := st
|
||||
t.Run(st.Name, func(t *testing.T) { f(t, st.Store, st.SqlSupplier) })
|
||||
}
|
||||
}
|
||||
|
||||
func initStores() {
|
||||
storeTypes = append(storeTypes, &storeType{
|
||||
Name: "LocalCache+MySQL",
|
||||
|
||||
@@ -315,22 +315,3 @@ func (w *Web) ApiSessionRequired(h func(*Context, http.ResponseWriter, *http.Req
|
||||
}
|
||||
return handler
|
||||
}
|
||||
|
||||
// apiHandlerTrustRequester provides a handler for API endpoints which do not require the user to be logged in and are
|
||||
// allowed to be requested directly rather than via javascript/XMLHttpRequest, such as site branding images or the
|
||||
// websocket.
|
||||
func (w *Web) apiHandlerTrustRequester(h func(*Context, http.ResponseWriter, *http.Request)) http.Handler {
|
||||
handler := &Handler{
|
||||
GetGlobalAppOptions: w.GetGlobalAppOptions,
|
||||
HandleFunc: h,
|
||||
HandlerName: GetHandlerName(h),
|
||||
RequireSession: false,
|
||||
TrustRequester: true,
|
||||
RequireMfa: false,
|
||||
IsStatic: false,
|
||||
}
|
||||
if *w.ConfigService.Config().ServiceSettings.WebserverMode == "gzip" {
|
||||
return gziphandler.GzipHandler(handler)
|
||||
}
|
||||
return handler
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user