mirror of
https://github.com/go-shiori/shiori.git
synced 2025-09-09 22:49:30 +08:00
fix: resolve linting errors and e2e test failures
- Fix ST1005 linting errors by lowercasing error message strings - Fix QF1008 linting errors by removing embedded field selectors in containers.go - Update Alpine version from 3.22 to 3.21 in Makefile to fix Docker image resolution - Update corresponding test expectations for error message changes
This commit is contained in:
parent
9f6a4c39d4
commit
ca949c5dab
7 changed files with 14 additions and 14 deletions
|
@ -60,9 +60,9 @@ func NewShioriContainer(t *testing.T, tag string) ShioriContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
if tag != "" {
|
if tag != "" {
|
||||||
containerDefinition.ContainerRequest.Image = "ghcr.io/go-shiori/shiori:" + tag
|
containerDefinition.Image = "ghcr.io/go-shiori/shiori:" + tag
|
||||||
} else {
|
} else {
|
||||||
containerDefinition.ContainerRequest.FromDockerfile = testcontainers.FromDockerfile{
|
containerDefinition.FromDockerfile = testcontainers.FromDockerfile{
|
||||||
PrintBuildLog: false,
|
PrintBuildLog: false,
|
||||||
Context: "../..",
|
Context: "../..",
|
||||||
Dockerfile: "Dockerfile.e2e",
|
Dockerfile: "Dockerfile.e2e",
|
||||||
|
|
|
@ -137,7 +137,7 @@ func (pr *PlaywrightRequire) True(t *testing.T, value bool, msgAndArgs ...interf
|
||||||
pr.Assert(t, func() error {
|
pr.Assert(t, func() error {
|
||||||
var err error
|
var err error
|
||||||
if !value {
|
if !value {
|
||||||
err = fmt.Errorf("Expected value to be true but got false in test '%s'", t.Name())
|
err = fmt.Errorf("expected value to be true but got false in test '%s'", t.Name())
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}, msgAndArgs...)
|
}, msgAndArgs...)
|
||||||
|
@ -149,7 +149,7 @@ func (pr *PlaywrightRequire) False(t *testing.T, value bool, msgAndArgs ...inter
|
||||||
pr.Assert(t, func() error {
|
pr.Assert(t, func() error {
|
||||||
var err error
|
var err error
|
||||||
if value {
|
if value {
|
||||||
err = fmt.Errorf("Expected value to be false but got true in test '%s'", t.Name())
|
err = fmt.Errorf("expected value to be false but got true in test '%s'", t.Name())
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}, msgAndArgs...)
|
}, msgAndArgs...)
|
||||||
|
@ -161,7 +161,7 @@ func (pr *PlaywrightRequire) Equal(t *testing.T, expected, actual interface{}, m
|
||||||
pr.Assert(t, func() error {
|
pr.Assert(t, func() error {
|
||||||
var err error
|
var err error
|
||||||
if expected != actual {
|
if expected != actual {
|
||||||
err = fmt.Errorf("Expected values to be equal in test '%s':\nexpected: %v\nactual: %v", t.Name(), expected, actual)
|
err = fmt.Errorf("expected values to be equal in test '%s':\nexpected: %v\nactual: %v", t.Name(), expected, actual)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}, msgAndArgs...)
|
}, msgAndArgs...)
|
||||||
|
@ -173,7 +173,7 @@ func (pr *PlaywrightRequire) NoError(t *testing.T, err error, msgAndArgs ...inte
|
||||||
pr.Assert(t, func() error {
|
pr.Assert(t, func() error {
|
||||||
var assertErr error
|
var assertErr error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
assertErr = fmt.Errorf("Expected no error but got error in test '%s': %v", t.Name(), err)
|
assertErr = fmt.Errorf("expected no error but got error in test '%s': %v", t.Name(), err)
|
||||||
}
|
}
|
||||||
return assertErr
|
return assertErr
|
||||||
}, msgAndArgs...)
|
}, msgAndArgs...)
|
||||||
|
@ -185,7 +185,7 @@ func (pr *PlaywrightRequire) Error(t *testing.T, err error, msgAndArgs ...interf
|
||||||
pr.Assert(t, func() error {
|
pr.Assert(t, func() error {
|
||||||
var assertErr error
|
var assertErr error
|
||||||
if err == nil {
|
if err == nil {
|
||||||
assertErr = fmt.Errorf("Expected error but got none in test '%s'", t.Name())
|
assertErr = fmt.Errorf("expected error but got none in test '%s'", t.Name())
|
||||||
}
|
}
|
||||||
return assertErr
|
return assertErr
|
||||||
}, msgAndArgs...)
|
}, msgAndArgs...)
|
||||||
|
@ -195,7 +195,7 @@ func (pr *PlaywrightRequire) Error(t *testing.T, err error, msgAndArgs ...interf
|
||||||
func (pr *PlaywrightRequire) Contains(t *testing.T, text, expected string, msgAndArgs ...interface{}) {
|
func (pr *PlaywrightRequire) Contains(t *testing.T, text, expected string, msgAndArgs ...interface{}) {
|
||||||
pr.Assert(t, func() error {
|
pr.Assert(t, func() error {
|
||||||
if !strings.Contains(text, expected) {
|
if !strings.Contains(text, expected) {
|
||||||
return fmt.Errorf("Expected text to contain '%s' but got '%s'", expected, text)
|
return fmt.Errorf("expected text to contain '%s' but got '%s'", expected, text)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}, msgAndArgs...)
|
}, msgAndArgs...)
|
||||||
|
|
|
@ -181,7 +181,7 @@ func verifyMetadata(title, url, timeAddedStr, tags string) (string, string, time
|
||||||
// Parse time added
|
// Parse time added
|
||||||
timeAddedInt, err := strconv.ParseInt(timeAddedStr, 10, 64)
|
timeAddedInt, err := strconv.ParseInt(timeAddedStr, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = fmt.Errorf("Invalid time added, %w", err)
|
err = fmt.Errorf("invalid time added, %w", err)
|
||||||
return "", "", time.Time{}, nil, err
|
return "", "", time.Time{}, nil, err
|
||||||
}
|
}
|
||||||
timeAdded := time.Unix(timeAddedInt, 0)
|
timeAdded := time.Unix(timeAddedInt, 0)
|
||||||
|
@ -211,7 +211,7 @@ func handleDuplicates(ctx context.Context, db model.DB, mapURL map[string]struct
|
||||||
|
|
||||||
_, exists, err := db.GetBookmark(ctx, 0, url)
|
_, exists, err := db.GetBookmark(ctx, 0, url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Failed getting bookmark, %w", err)
|
return fmt.Errorf("failed getting bookmark, %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if exists {
|
if exists {
|
||||||
|
|
|
@ -90,7 +90,7 @@ func (c *HttpConfig) IsValid() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.ServeWebUIV2 && !c.ServeWebUI {
|
if c.ServeWebUIV2 && !c.ServeWebUI {
|
||||||
return fmt.Errorf("You need to enable serving the Web UI to use the experimental Web UI v2")
|
return fmt.Errorf("you need to enable serving the Web UI to use the experimental Web UI v2")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -25,7 +25,7 @@ func (d *AuthDomain) CheckToken(ctx context.Context, userJWT string) (*model.Acc
|
||||||
token, err := jwt.ParseWithClaims(userJWT, &JWTClaim{}, func(token *jwt.Token) (interface{}, error) {
|
token, err := jwt.ParseWithClaims(userJWT, &JWTClaim{}, func(token *jwt.Token) (interface{}, error) {
|
||||||
// Validate algorithm
|
// Validate algorithm
|
||||||
if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok {
|
if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok {
|
||||||
return nil, fmt.Errorf("Unexpected signing method: %v", token.Header["alg"])
|
return nil, fmt.Errorf("unexpected signing method: %v", token.Header["alg"])
|
||||||
}
|
}
|
||||||
|
|
||||||
return d.deps.Config().Http.SecretKey, nil
|
return d.deps.Config().Http.SecretKey, nil
|
||||||
|
|
|
@ -82,7 +82,7 @@ func TestAuthDomainCheckTokenInvalidMethod(t *testing.T) {
|
||||||
acc, err := domain.CheckToken(ctx, tokenString)
|
acc, err := domain.CheckToken(ctx, tokenString)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
require.Nil(t, acc)
|
require.Nil(t, acc)
|
||||||
require.Contains(t, err.Error(), "Unexpected signing method")
|
require.Contains(t, err.Error(), "unexpected signing method")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAuthDomainGetAccountFromCredentials(t *testing.T) {
|
func TestAuthDomainGetAccountFromCredentials(t *testing.T) {
|
||||||
|
|
|
@ -127,7 +127,7 @@ type updateAccountPayload struct {
|
||||||
|
|
||||||
func (p *updateAccountPayload) IsValid() error {
|
func (p *updateAccountPayload) IsValid() error {
|
||||||
if p.NewPassword != "" && p.OldPassword == "" {
|
if p.NewPassword != "" && p.OldPassword == "" {
|
||||||
return fmt.Errorf("To update the password the old one must be provided")
|
return fmt.Errorf("to update the password the old one must be provided")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue