Files
Crussell/backend/internal/square/square_dev_prod_test.go
T
popertots 3029fd5179
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
test: add coverage tests across backend + fix mock for PENDING checkout support
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)
2026-07-10 18:13:44 +01:00

92 lines
2.5 KiB
Go

//go:build test && dev
package square
import (
"context"
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestDevProdClient_CreatePayment(t *testing.T) {
saved := os.Getenv("SQUARE_ENVIRONMENT")
os.Setenv("SQUARE_ENVIRONMENT", "sandbox")
defer os.Setenv("SQUARE_ENVIRONMENT", saved)
client := NewDevClient()
_, err := client.CreatePayment(context.Background(), CreatePaymentReq{})
assert.Error(t, err)
}
func TestDevProdClient_CreateCheckout(t *testing.T) {
saved := os.Getenv("SQUARE_ENVIRONMENT")
os.Setenv("SQUARE_ENVIRONMENT", "sandbox")
defer os.Setenv("SQUARE_ENVIRONMENT", saved)
client := NewDevClient()
_, err := client.CreateCheckout(context.Background(), CreateCheckoutReq{})
assert.Error(t, err)
}
func TestDevProdClient_GetCheckout(t *testing.T) {
saved := os.Getenv("SQUARE_ENVIRONMENT")
os.Setenv("SQUARE_ENVIRONMENT", "sandbox")
defer os.Setenv("SQUARE_ENVIRONMENT", saved)
client := NewDevClient()
_, err := client.GetCheckout(context.Background(), "")
assert.Error(t, err)
}
func TestDevProdClient_RefundPayment(t *testing.T) {
saved := os.Getenv("SQUARE_ENVIRONMENT")
os.Setenv("SQUARE_ENVIRONMENT", "sandbox")
defer os.Setenv("SQUARE_ENVIRONMENT", saved)
client := NewDevClient()
_, err := client.RefundPayment(context.Background(), RefundPaymentReq{})
assert.Error(t, err)
}
func TestDevProdClient_CreateCardOnFile(t *testing.T) {
saved := os.Getenv("SQUARE_ENVIRONMENT")
os.Setenv("SQUARE_ENVIRONMENT", "sandbox")
defer os.Setenv("SQUARE_ENVIRONMENT", saved)
client := NewDevClient()
_, err := client.CreateCardOnFile(context.Background(), "", "")
assert.Error(t, err)
}
func TestDevProdClient_CreateCardOnFileRaw(t *testing.T) {
saved := os.Getenv("SQUARE_ENVIRONMENT")
os.Setenv("SQUARE_ENVIRONMENT", "sandbox")
defer os.Setenv("SQUARE_ENVIRONMENT", saved)
client := NewDevClient()
_, err := client.CreateCardOnFileRaw(context.Background(), "", "", 0, 0, "")
assert.Error(t, err)
}
func TestDevProdClient_GetCardsOnFile(t *testing.T) {
saved := os.Getenv("SQUARE_ENVIRONMENT")
os.Setenv("SQUARE_ENVIRONMENT", "sandbox")
defer os.Setenv("SQUARE_ENVIRONMENT", saved)
client := NewDevClient()
_, err := client.GetCardsOnFile(context.Background(), "")
assert.Error(t, err)
}
func TestDevProdClient_DeleteCardOnFile(t *testing.T) {
saved := os.Getenv("SQUARE_ENVIRONMENT")
os.Setenv("SQUARE_ENVIRONMENT", "sandbox")
defer os.Setenv("SQUARE_ENVIRONMENT", saved)
client := NewDevClient()
err := client.DeleteCardOnFile(context.Background(), "")
assert.Error(t, err)
}