Skip to content

Commit 8613433

Browse files
feat(compat): wire compat/formats §4 attestation (#33)
Adds TestContractFormats sibling to the existing TestContractDates, running formats.RunContract against the same five data-producing subcommands. Bumps github.com/quantcli/common/compat to the version that includes the formats bundle (QUA-15) and the SkipDataPath / SupportedFormats affordances (QUA-21, QUA-28). - SupportedFormats: ["markdown","json"] declares the codec subset crono actually implements; CSVHasHeader skips with a named reason rather than failing. - SkipDataPath: true opts out of the JSONIsArray/CSVHasHeader/ DefaultIsMarkdown data-path subtests because crono's data path requires CRONOMETER_USERNAME/PASSWORD which the compat CI job does not provide. Parse-level subtests (HelpDocumentsFormatFlag, UnknownFormatFails, FlagValidationIsHermetic) still attest the §4 surface. - CI compat job's -run filter expands to TestContract(Dates|Formats). Reuses the existing compat job; no new workflow. Verified locally (CRONO_EXPORT_BIN=/tmp/crono-export): TestContractDates 20/20 PASS (5 subcommands × 4 subtests) TestContractFormats 15 PASS / 15 SKIP (5 × {3 parse PASS + 3 data-path SKIP}) Refs: QUA-19. Co-authored-by: Paperclip <noreply@paperclip.ing>
1 parent 04aaae9 commit 8613433

4 files changed

Lines changed: 44 additions & 12 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ jobs:
4444
env:
4545
# Path the compat-tagged test reads from os.Getenv.
4646
CRONO_EXPORT_BIN: /tmp/crono-export
47-
run: go test -tags=compat -run TestContractDates ./...
47+
run: go test -tags=compat -run 'TestContract(Dates|Formats)' ./...

compat_contract_test.go

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,21 @@ import (
1717

1818
"github.com/quantcli/common/compat"
1919
"github.com/quantcli/common/compat/dates"
20+
"github.com/quantcli/common/compat/formats"
2021
)
2122

23+
// cronoSubcommands is the §3/§4 surface for crono — each subcommand
24+
// owns its own --since/--until and --format flags. Shared between the
25+
// dates and formats bundles so a single source-of-truth list keeps
26+
// the two suites in sync.
27+
var cronoSubcommands = []string{
28+
"biometrics",
29+
"exercises",
30+
"nutrition",
31+
"servings",
32+
"notes",
33+
}
34+
2235
func TestContractDates(t *testing.T) {
2336
bin := os.Getenv("CRONO_EXPORT_BIN")
2437
if bin == "" {
@@ -29,13 +42,32 @@ func TestContractDates(t *testing.T) {
2942
// subcommand under a `subcommand=NAME/...` subtree so any single
3043
// regression surfaces as a named subtest failure.
3144
dates.RunContract(t, compat.Runner{
32-
Binary: bin,
33-
Subcommands: []string{
34-
"biometrics",
35-
"exercises",
36-
"nutrition",
37-
"servings",
38-
"notes",
39-
},
45+
Binary: bin,
46+
Subcommands: cronoSubcommands,
47+
})
48+
}
49+
50+
func TestContractFormats(t *testing.T) {
51+
bin := os.Getenv("CRONO_EXPORT_BIN")
52+
if bin == "" {
53+
t.Skip("CRONO_EXPORT_BIN not set; skipping compat suite")
54+
}
55+
// crono implements --format markdown (default) and --format json
56+
// today; CSV is not yet wired (see cmd/format.go chosenFormat).
57+
// SupportedFormats: ["markdown","json"] skips CSVHasHeader with a
58+
// named reason rather than failing it.
59+
//
60+
// SkipDataPath: true opts out of JSONIsArray / CSVHasHeader /
61+
// DefaultIsMarkdown — crono's data path requires
62+
// CRONOMETER_USERNAME/PASSWORD which the compat CI job does not
63+
// provide, so the data-path subtests would fail at "not logged in"
64+
// before the codec assertions could run. The parse-level subtests
65+
// (HelpDocumentsFormatFlag, UnknownFormatFails,
66+
// FlagValidationIsHermetic) still attest the §4 surface.
67+
formats.RunContract(t, compat.Runner{
68+
Binary: bin,
69+
Subcommands: cronoSubcommands,
70+
SupportedFormats: []string{"markdown", "json"},
71+
SkipDataPath: true,
4072
})
4173
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/quantcli/crono-export-cli
33
go 1.25.10
44

55
require (
6-
github.com/quantcli/common/compat v0.0.0-20260510225630-4c588c19cd1b
6+
github.com/quantcli/common/compat v0.0.0-20260511224412-1cf4a39648c5
77
github.com/spf13/cobra v1.10.2
88
)
99

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
22
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
33
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
4-
github.com/quantcli/common/compat v0.0.0-20260510225630-4c588c19cd1b h1:fO7EfkEqzLRC8Ev22jIq05fPs+JwAB7bCDy6FA+GA5k=
5-
github.com/quantcli/common/compat v0.0.0-20260510225630-4c588c19cd1b/go.mod h1:VBC/zEphSZgCZS1rhWsR3A8EWYSbTkP/MwqWHL7266s=
4+
github.com/quantcli/common/compat v0.0.0-20260511224412-1cf4a39648c5 h1:UW6c2rz3bbk2Ju0lGv+QqmuU7+SkIQMFkBJPSr+LDGc=
5+
github.com/quantcli/common/compat v0.0.0-20260511224412-1cf4a39648c5/go.mod h1:VBC/zEphSZgCZS1rhWsR3A8EWYSbTkP/MwqWHL7266s=
66
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
77
github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU=
88
github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4=

0 commit comments

Comments
 (0)