forked from mirrors/homebox
chore: developer cleanup (#300)
* new PR tasks * add homebox to know words * formatting * bump deps * generate db models * ts errors * drop id * fix accessor * drop unused time field * change CI * add expected error * add type check * resolve serveral type errors * hoise in CI
This commit is contained in:
parent
88f9ff90d4
commit
bd321af29f
142 changed files with 817 additions and 1200 deletions
|
@ -7,8 +7,7 @@ import (
|
|||
|
||||
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
|
||||
|
||||
type Faker struct {
|
||||
}
|
||||
type Faker struct{}
|
||||
|
||||
func NewFaker() *Faker {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
|
@ -20,7 +19,6 @@ func (f *Faker) Time() time.Time {
|
|||
}
|
||||
|
||||
func (f *Faker) Str(length int) string {
|
||||
|
||||
b := make([]rune, length)
|
||||
for i := range b {
|
||||
b[i] = letters[rand.Intn(len(letters))]
|
||||
|
|
|
@ -20,7 +20,7 @@ func ValidateUnique(values []string) bool {
|
|||
func Test_GetRandomString(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Test that the function returns a string of the correct length
|
||||
var generated = make([]string, Loops)
|
||||
generated := make([]string, Loops)
|
||||
|
||||
faker := NewFaker()
|
||||
|
||||
|
@ -36,7 +36,7 @@ func Test_GetRandomString(t *testing.T) {
|
|||
func Test_GetRandomEmail(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Test that the function returns a string of the correct length
|
||||
var generated = make([]string, Loops)
|
||||
generated := make([]string, Loops)
|
||||
|
||||
faker := NewFaker()
|
||||
|
||||
|
@ -52,8 +52,8 @@ func Test_GetRandomEmail(t *testing.T) {
|
|||
func Test_GetRandomBool(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var trues = 0
|
||||
var falses = 0
|
||||
trues := 0
|
||||
falses := 0
|
||||
|
||||
faker := NewFaker()
|
||||
|
||||
|
@ -91,5 +91,4 @@ func Test_RandomNumber(t *testing.T) {
|
|||
t.Errorf("RandomNumber() failed to generate a number between %v and %v", MIN, MAX)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,14 +30,12 @@ func GetTestMailer() (*Mailer, error) {
|
|||
}
|
||||
|
||||
return mailer, nil
|
||||
|
||||
}
|
||||
|
||||
func Test_Mailer(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
mailer, err := GetTestMailer()
|
||||
|
||||
if err != nil {
|
||||
t.Skip("Error Reading Test Mailer Config - Skipping")
|
||||
}
|
||||
|
@ -47,7 +45,6 @@ func Test_Mailer(t *testing.T) {
|
|||
}
|
||||
|
||||
message, err := RenderWelcome()
|
||||
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
|
|
@ -41,7 +41,6 @@ func DefaultTemplateData() TemplateProps {
|
|||
|
||||
func render(tpl string, data TemplateProps) (string, error) {
|
||||
tmpl, err := template.New("name").Parse(tpl)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ type Middleware func(Handler) Handler
|
|||
// handler. The middlewares' Handlers will be executed by requests in the order
|
||||
// they are provided.
|
||||
func wrapMiddleware(mw []Middleware, handler Handler) Handler {
|
||||
|
||||
// Loop backwards through the middleware invoking each one. Replace the
|
||||
// handler with the new wrapped handler. Looping backwards ensures that the
|
||||
// first middleware of the slice is the first to be executed by requests.
|
||||
|
|
|
@ -40,7 +40,6 @@ func (s *Server) toHttpHandler(handler Handler, mw ...Middleware) http.HandlerFu
|
|||
})
|
||||
|
||||
err := handler.ServeHTTP(w, r.WithContext(ctx))
|
||||
|
||||
if err != nil {
|
||||
if IsShutdownError(err) {
|
||||
_ = s.Shutdown("SIGTERM")
|
||||
|
|
|
@ -37,5 +37,4 @@ func Test_Respond_JSON(t *testing.T) {
|
|||
assert.Equal(t, http.StatusCreated, recorder.Code)
|
||||
assert.JSONEq(t, recorder.Body.String(), `{"name":"dummy"}`)
|
||||
assert.Equal(t, "application/json", recorder.Header().Get("Content-Type"))
|
||||
|
||||
}
|
||||
|
|
|
@ -79,7 +79,6 @@ func (s *Server) Shutdown(sig string) error {
|
|||
s.wg.Wait()
|
||||
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
func (s *Server) Start() error {
|
||||
|
|
|
@ -72,7 +72,6 @@ func Test_GracefulServerShutdownWithWorkers(t *testing.T) {
|
|||
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, isFinished)
|
||||
|
||||
}
|
||||
|
||||
func Test_GracefulServerShutdownWithRequests(t *testing.T) {
|
||||
|
|
|
@ -10,8 +10,7 @@ type Worker interface {
|
|||
// the Worker interface and runs all tasks in a go routine without
|
||||
// a pool or que or limits. It's useful for simple or small applications
|
||||
// with minimal/short background tasks
|
||||
type SimpleWorker struct {
|
||||
}
|
||||
type SimpleWorker struct{}
|
||||
|
||||
func NewSimpleWorker() *SimpleWorker {
|
||||
return &SimpleWorker{}
|
||||
|
|
|
@ -97,5 +97,4 @@ func Disjoint[T key](a, b Set[T]) bool {
|
|||
}
|
||||
}
|
||||
return true
|
||||
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ var (
|
|||
)
|
||||
|
||||
func TestDiff(t *testing.T) {
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue