carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package economics
2
3import (
4 "encoding/json"
5 "strings"
6 "testing"
7)
8
9// TestManualBillMarshalsWithoutPulledAt: a SourceManual bill never sets
10// PulledAt, and encoding/json's omitempty does NOT treat a zero time.Time as
11// empty — omitzero does. A manual bill that marshalled a pulled_at key would
12// lie: "0001-01-01T00:00:00Z" reads as a real pull that never happened.
13func TestManualBillMarshalsWithoutPulledAt(t *testing.T) {
14 b := Bill{
15 Schema: 1,
16 Month: "2026-08",
17 TotalUSD: 42.5,
18 Services: map[string]float64{"AmazonEC2": 42.5},
19 Source: SourceManual,
20 }
21 raw, err := json.Marshal(b)
22 if err != nil {
23 t.Fatal(err)
24 }
25 if strings.Contains(string(raw), "pulled_at") {
26 t.Fatalf("manual bill marshalled a pulled_at key: %s", raw)
27 }
28}
29