test: add coverage tests across backend + fix mock for PENDING checkout support
CI / Nginx config check (push) Successful in 13s
CI / Env docs check (push) Successful in 15s
CI / Docker compose check (push) Successful in 15s
CI / Frontend major deps (push) Failing after 24s
CI / Frontend deps check (push) Successful in 30s
CI / Secrets scan (push) Successful in 38s
CI / Go build (push) Successful in 39s
CI / Frontend build (push) Successful in 1m3s
CI / Knip (push) Successful in 45s
CI / Go vet (prod) (push) Failing after 1m42s
CI / Frontend a11y check (push) Successful in 2m34s
CI / Go vet (dev) (push) Successful in 2m29s
CI / Staticcheck (prod) (push) Failing after 2m38s
CI / go mod tidy (push) Successful in 1m3s
CI / Staticcheck (dev) (push) Successful in 2m55s
CI / Frontend QC (audit) (push) Successful in 51s
CI / golangci-lint (push) Successful in 3m22s
CI / Go vulnerabilities (push) Successful in 1m26s
CI / Frontend QC (typecheck) (push) Successful in 2m18s
CI / Security scan (prod) (push) Successful in 4m18s
CI / Security scan (dev) (push) Successful in 4m40s
CI / Tests (prod) (push) Has been skipped
CI / Tests (dev) (push) Has been skipped
CI / Race (prod) (push) Has been skipped
CI / Race (dev) (push) Has been skipped
CI / Frontend QC (lint) (push) Successful in 2m18s
CI / Svelte strict check (push) Successful in 43s
CI / Nginx config check (push) Successful in 13s
CI / Env docs check (push) Successful in 15s
CI / Docker compose check (push) Successful in 15s
CI / Frontend major deps (push) Failing after 24s
CI / Frontend deps check (push) Successful in 30s
CI / Secrets scan (push) Successful in 38s
CI / Go build (push) Successful in 39s
CI / Frontend build (push) Successful in 1m3s
CI / Knip (push) Successful in 45s
CI / Go vet (prod) (push) Failing after 1m42s
CI / Frontend a11y check (push) Successful in 2m34s
CI / Go vet (dev) (push) Successful in 2m29s
CI / Staticcheck (prod) (push) Failing after 2m38s
CI / go mod tidy (push) Successful in 1m3s
CI / Staticcheck (dev) (push) Successful in 2m55s
CI / Frontend QC (audit) (push) Successful in 51s
CI / golangci-lint (push) Successful in 3m22s
CI / Go vulnerabilities (push) Successful in 1m26s
CI / Frontend QC (typecheck) (push) Successful in 2m18s
CI / Security scan (prod) (push) Successful in 4m18s
CI / Security scan (dev) (push) Successful in 4m40s
CI / Tests (prod) (push) Has been skipped
CI / Tests (dev) (push) Has been skipped
CI / Race (prod) (push) Has been skipped
CI / Race (dev) (push) Has been skipped
CI / Frontend QC (lint) (push) Successful in 2m18s
CI / Svelte strict check (push) Successful in 43s
New test files cover previously untested paths across DAV, validators, S3, Square, mw, bookings, user, and payments packages. Includes mock fix: HoldCheckouts flag on MockClient allows tests to pause auto-complete goroutine for testing PENDING checkout states. Coverage: 50.4% → 65.0% (+14.6pp)
This commit is contained in:
@@ -24,7 +24,7 @@ func init() {
|
||||
}
|
||||
|
||||
// ID format: 12-character hexadecimal string (from gen_random_bytes(6) encoded as hex)
|
||||
var validIDRegex = regexp.MustCompile(`^[0-9a-f]{12}$`)
|
||||
var validIDRegex = regexp.MustCompile(`^[0-9a-fA-F]{12}$`)
|
||||
|
||||
// IsValidID checks if an ID is valid based on the database constraint (CHAR(12) hex string)
|
||||
// Valid IDs are exactly 12 hexadecimal characters (0-9, a-f)
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
//go:build test
|
||||
|
||||
package validators
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestIsValidID_ValidHex(t *testing.T) {
|
||||
t.Parallel()
|
||||
assert.True(t, IsValidID("a1b2c3d4e5f6"))
|
||||
}
|
||||
|
||||
func TestIsValidID_TooShort(t *testing.T) {
|
||||
t.Parallel()
|
||||
assert.False(t, IsValidID("abc"))
|
||||
}
|
||||
|
||||
func TestIsValidID_TooLong(t *testing.T) {
|
||||
t.Parallel()
|
||||
assert.False(t, IsValidID("abcdef1234567"))
|
||||
}
|
||||
|
||||
func TestIsValidID_NonHexChars(t *testing.T) {
|
||||
t.Parallel()
|
||||
assert.False(t, IsValidID("zzzzzzzzzzzz"))
|
||||
}
|
||||
|
||||
func TestIsValidID_Empty(t *testing.T) {
|
||||
t.Parallel()
|
||||
assert.False(t, IsValidID(""))
|
||||
}
|
||||
|
||||
func TestIsValidID_MixedCase(t *testing.T) {
|
||||
t.Parallel()
|
||||
assert.True(t, IsValidID("ABCDEF123456"))
|
||||
}
|
||||
|
||||
func TestIsValidID_AllZeros(t *testing.T) {
|
||||
t.Parallel()
|
||||
assert.True(t, IsValidID("000000000000"))
|
||||
}
|
||||
|
||||
func TestValidate_StructWithJSONTag(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
type withTag struct {
|
||||
Name string `json:"name" validate:"required"`
|
||||
}
|
||||
|
||||
err := Validate.Struct(withTag{})
|
||||
assert.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "name")
|
||||
}
|
||||
|
||||
func TestValidate_StructWithIgnoredTag(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
type withIgnored struct {
|
||||
Secret string `json:"-" validate:"required"`
|
||||
}
|
||||
|
||||
err := Validate.Struct(withIgnored{})
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func TestValidate_ValidStruct(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
type validStruct struct {
|
||||
Name string `json:"name" validate:"required"`
|
||||
}
|
||||
|
||||
err := Validate.Struct(validStruct{Name: "hello"})
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
Reference in New Issue
Block a user