LINUS ROUND 1: Delete dead code (rust/c), generic Store[T], tests, slim main.go
- Removed rust-service/, c-runtime/, kafka stubs - Generic Store[T] pattern with real tests - Slimmed main.go from 324 to ~50 lines - Added config, middleware, store, ledger, pdf tests - Frontend SPA shell with router - Binary: 15.5MB -> 12MB
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
package pdf
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestGenerateDocument_Invoice(t *testing.T) {
|
||||
data := DocumentData{
|
||||
DocType: InvoiceDoc,
|
||||
DocNumber: "INV-001",
|
||||
DocDate: time.Now(),
|
||||
CustomerName: "Test AB",
|
||||
CustomerAddress: "Testgatan 1, Stockholm",
|
||||
Items: []LineItem{
|
||||
{Description: "Konsulting", Quantity: 10, Unit: "tim", UnitPrice: 1000, Total: 10000},
|
||||
},
|
||||
Subtotal: 10000,
|
||||
VATRate: 0.25,
|
||||
VATAmount: 2500,
|
||||
Total: 12500,
|
||||
Currency: "USD",
|
||||
CompanyName: "Landvex Inc",
|
||||
CompanyAddress: "Houston, TX",
|
||||
Notes: "Betalningsvillkor: 30 dagar",
|
||||
}
|
||||
|
||||
pdfBytes, err := GenerateDocument(data)
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, pdfBytes)
|
||||
assert.Greater(t, len(pdfBytes), 1000)
|
||||
|
||||
// PDF magic number
|
||||
assert.Equal(t, "%PDF", string(pdfBytes[:4]))
|
||||
}
|
||||
|
||||
func TestGenerateDocument_Quote(t *testing.T) {
|
||||
validUntil := time.Now().AddDate(0, 1, 0)
|
||||
data := DocumentData{
|
||||
DocType: QuoteDoc,
|
||||
DocNumber: "Q-001",
|
||||
DocDate: time.Now(),
|
||||
ValidUntil: &validUntil,
|
||||
CustomerName: "Test AB",
|
||||
CustomerAddress: "Testgatan 1",
|
||||
Items: []LineItem{
|
||||
{Description: "Produkt A", Quantity: 5, Unit: "st", UnitPrice: 500, Total: 2500},
|
||||
},
|
||||
Subtotal: 2500,
|
||||
VATRate: 0.25,
|
||||
VATAmount: 625,
|
||||
Total: 3125,
|
||||
Currency: "USD",
|
||||
CompanyName: "Landvex Inc",
|
||||
CompanyAddress: "Houston, TX",
|
||||
}
|
||||
|
||||
pdfBytes, err := GenerateDocument(data)
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, pdfBytes)
|
||||
assert.Equal(t, "%PDF", string(pdfBytes[:4]))
|
||||
}
|
||||
|
||||
func TestDocInfoLabel(t *testing.T) {
|
||||
assert.Equal(t, "FAKTURAINFORMATION", docInfoLabel(InvoiceDoc))
|
||||
assert.Equal(t, "OFFERTINFORMATION", docInfoLabel(QuoteDoc))
|
||||
}
|
||||
|
||||
func TestDocNumberLabel(t *testing.T) {
|
||||
assert.Equal(t, "Fakturanr", docNumberLabel(InvoiceDoc))
|
||||
assert.Equal(t, "Offertnr", docNumberLabel(QuoteDoc))
|
||||
}
|
||||
Reference in New Issue
Block a user