bf9395e022
CI / license-header (push) Has been skipped
CI / e2e-dry-run (push) Has been skipped
CI / fast-gate (push) Failing after 0s
Test PR Label Logic / test-pr-labels (push) Failing after 1s
Skill Format Check / check-format (push) Failing after 2s
CI / security (push) Failing after 5s
CI / unit-test (push) Has been skipped
CI / lint (push) Has been skipped
CI / script-test (push) Has been skipped
CI / deterministic-gate (push) Has been skipped
CI / coverage (push) Has been skipped
CI / results (push) Has been cancelled
CI / deadcode (push) Has been cancelled
CI / e2e-live (push) Has been cancelled
34 lines
1.0 KiB
Go
34 lines
1.0 KiB
Go
// Copyright (c) 2026 Lark Technologies Pte. Ltd.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package sheets
|
|
|
|
import (
|
|
_ "embed"
|
|
"encoding/json"
|
|
"reflect"
|
|
"testing"
|
|
)
|
|
|
|
// flagDefsJSONForTest embeds the source data only in tests; production code
|
|
// reads the compiled flagDefs map (flag_defs_gen.go) and never unmarshals.
|
|
//
|
|
//go:embed data/flag-defs.json
|
|
var flagDefsJSONForTest []byte
|
|
|
|
// TestFlagDefsGen_MatchesJSON guards against drift between the compiled
|
|
// flagDefs map (flag_defs_gen.go) and its source data/flag-defs.json: if the
|
|
// JSON is regenerated without re-running the codegen (or vice versa), this
|
|
// fails. This equivalence is exactly what lets production code skip the
|
|
// runtime unmarshal.
|
|
func TestFlagDefsGen_MatchesJSON(t *testing.T) {
|
|
t.Parallel()
|
|
var fromJSON map[string]commandDef
|
|
if err := json.Unmarshal(flagDefsJSONForTest, &fromJSON); err != nil {
|
|
t.Fatalf("unmarshal flag-defs.json: %v", err)
|
|
}
|
|
if !reflect.DeepEqual(fromJSON, flagDefs) {
|
|
t.Error("compiled flagDefs differs from data/flag-defs.json; regenerate flag_defs_gen.go")
|
|
}
|
|
}
|