feat: contact form backend for linux and freebsd servers
Test / test (push) Successful in 2m1s
Release / gates (push) Successful in 1m57s
Release / build (amd64, freebsd) (push) Successful in 1m26s
Release / build (amd64, linux) (push) Successful in 1m30s
Release / build (arm64, freebsd) (push) Successful in 1m28s
Release / build (arm64, linux) (push) Successful in 1m49s
Release / build (loong64, linux) (push) Successful in 1m30s
Release / build (riscv64, linux) (push) Successful in 1m29s
Release / release (push) Successful in 41s
Test / test (push) Successful in 2m1s
Release / gates (push) Successful in 1m57s
Release / build (amd64, freebsd) (push) Successful in 1m26s
Release / build (amd64, linux) (push) Successful in 1m30s
Release / build (arm64, freebsd) (push) Successful in 1m28s
Release / build (arm64, linux) (push) Successful in 1m49s
Release / build (loong64, linux) (push) Successful in 1m30s
Release / build (riscv64, linux) (push) Successful in 1m29s
Release / release (push) Successful in 41s
Assisted-by: GLM 5.3 Flash
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
//go:build linux || freebsd
|
||||
|
||||
package storage
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestArchiveStoreRoundTrip(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "nested", "archive-test.jsonl")
|
||||
store := NewArchiveStore(path)
|
||||
|
||||
first := Submission{
|
||||
Form: "contact",
|
||||
Name: "Jane Doe",
|
||||
Email: "jane@example.com",
|
||||
Service: "architecture",
|
||||
Message: "Hello, I would like to discuss an engagement.",
|
||||
IP: "192.0.2.1",
|
||||
}
|
||||
if err := store.Append(first); err != nil {
|
||||
t.Fatalf("append: %v", err)
|
||||
}
|
||||
second := Submission{Form: "feedback", Email: "other@example.com", Message: "Short"}
|
||||
if err := store.Append(second); err != nil {
|
||||
t.Fatalf("append: %v", err)
|
||||
}
|
||||
|
||||
f, err := os.Open(path)
|
||||
if err != nil {
|
||||
t.Fatalf("open: %v", err)
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
var got []Submission
|
||||
scanner := bufio.NewScanner(f)
|
||||
for scanner.Scan() {
|
||||
var sub Submission
|
||||
if err := json.Unmarshal(scanner.Bytes(), &sub); err != nil {
|
||||
t.Fatalf("unmarshal line: %v", err)
|
||||
}
|
||||
got = append(got, sub)
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
t.Fatalf("scan: %v", err)
|
||||
}
|
||||
if len(got) != 2 {
|
||||
t.Fatalf("lines = %d, want 2", len(got))
|
||||
}
|
||||
if got[0].CreatedAt.IsZero() {
|
||||
t.Errorf("first created_at is zero, want a stamped time")
|
||||
}
|
||||
first.CreatedAt = got[0].CreatedAt
|
||||
if got[0] != first {
|
||||
t.Errorf("first = %+v, want %+v", got[0], first)
|
||||
}
|
||||
if got[1].CreatedAt.IsZero() {
|
||||
t.Errorf("second created_at is zero, want a stamped time")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user