Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ jobs:
env:
# Path the compat-tagged test reads from os.Getenv.
CRONO_EXPORT_BIN: /tmp/crono-export
run: go test -tags=compat -run TestContractDates ./...
run: go test -tags=compat -run 'TestContract(Dates|Formats)' ./...
48 changes: 40 additions & 8 deletions compat_contract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,21 @@ import (

"github.com/quantcli/common/compat"
"github.com/quantcli/common/compat/dates"
"github.com/quantcli/common/compat/formats"
)

// cronoSubcommands is the §3/§4 surface for crono — each subcommand
// owns its own --since/--until and --format flags. Shared between the
// dates and formats bundles so a single source-of-truth list keeps
// the two suites in sync.
var cronoSubcommands = []string{
"biometrics",
"exercises",
"nutrition",
"servings",
"notes",
}

func TestContractDates(t *testing.T) {
bin := os.Getenv("CRONO_EXPORT_BIN")
if bin == "" {
Expand All @@ -29,13 +42,32 @@ func TestContractDates(t *testing.T) {
// subcommand under a `subcommand=NAME/...` subtree so any single
// regression surfaces as a named subtest failure.
dates.RunContract(t, compat.Runner{
Binary: bin,
Subcommands: []string{
"biometrics",
"exercises",
"nutrition",
"servings",
"notes",
},
Binary: bin,
Subcommands: cronoSubcommands,
})
}

func TestContractFormats(t *testing.T) {
bin := os.Getenv("CRONO_EXPORT_BIN")
if bin == "" {
t.Skip("CRONO_EXPORT_BIN not set; skipping compat suite")
}
// crono implements --format markdown (default) and --format json
// today; CSV is not yet wired (see cmd/format.go chosenFormat).
// SupportedFormats: ["markdown","json"] skips CSVHasHeader with a
// named reason rather than failing it.
//
// SkipDataPath: true opts out of JSONIsArray / CSVHasHeader /
// DefaultIsMarkdown — crono's data path requires
// CRONOMETER_USERNAME/PASSWORD which the compat CI job does not
// provide, so the data-path subtests would fail at "not logged in"
// before the codec assertions could run. The parse-level subtests
// (HelpDocumentsFormatFlag, UnknownFormatFails,
// FlagValidationIsHermetic) still attest the §4 surface.
formats.RunContract(t, compat.Runner{
Binary: bin,
Subcommands: cronoSubcommands,
SupportedFormats: []string{"markdown", "json"},
SkipDataPath: true,
})
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/quantcli/crono-export-cli
go 1.25.10

require (
github.com/quantcli/common/compat v0.0.0-20260510225630-4c588c19cd1b
github.com/quantcli/common/compat v0.0.0-20260511224412-1cf4a39648c5
github.com/spf13/cobra v1.10.2
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/quantcli/common/compat v0.0.0-20260510225630-4c588c19cd1b h1:fO7EfkEqzLRC8Ev22jIq05fPs+JwAB7bCDy6FA+GA5k=
github.com/quantcli/common/compat v0.0.0-20260510225630-4c588c19cd1b/go.mod h1:VBC/zEphSZgCZS1rhWsR3A8EWYSbTkP/MwqWHL7266s=
github.com/quantcli/common/compat v0.0.0-20260511224412-1cf4a39648c5 h1:UW6c2rz3bbk2Ju0lGv+QqmuU7+SkIQMFkBJPSr+LDGc=
github.com/quantcli/common/compat v0.0.0-20260511224412-1cf4a39648c5/go.mod h1:VBC/zEphSZgCZS1rhWsR3A8EWYSbTkP/MwqWHL7266s=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU=
github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4=
Expand Down
Loading