Files
wehub-resource-sync 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
chore: import upstream snapshot with attribution
2026-07-13 12:22:54 +08:00

46 lines
1.3 KiB
Go

// Copyright (c) 2026 Lark Technologies Pte. Ltd.
// SPDX-License-Identifier: MIT
package domaincontract
import (
"errors"
"os"
"os/exec"
"strings"
"testing"
)
// TestLintcheckExitCode proves the guard gates CI end to end: a violating
// fixture must make the lintcheck binary exit 1, and a clean tree exit 0.
func TestLintcheckExitCode(t *testing.T) {
if testing.Short() {
t.Skip("compiles the lintcheck binary")
}
dirty := t.TempDir()
writeFile(t, dirty, "internal/x/x.go", "package x\n\nvar h = \"https://open.feishu.cn\"\n")
run := func(dir string) (string, error) {
cmd := exec.Command("go", "run", "..", dir)
cmd.Dir = "." // lint/domaincontract — `..` is the lintcheck main package
cmd.Env = os.Environ()
out, err := cmd.CombinedOutput()
return string(out), err
}
out, err := run(dirty)
if err == nil || !strings.Contains(out, "no-hardcoded-endpoint") {
t.Fatalf("violating fixture: err=%v out=%s (want exit 1 with a no-hardcoded-endpoint REJECT)", err, out)
}
var exitErr *exec.ExitError
if !errors.As(err, &exitErr) || exitErr.ExitCode() != 1 {
t.Fatalf("violating fixture exit = %v, want 1", err)
}
clean := t.TempDir()
writeFile(t, clean, "internal/x/x.go", "package x\n\nvar ok = 1\n")
if out, err := run(clean); err != nil {
t.Fatalf("clean fixture: err=%v out=%s (want exit 0)", err, out)
}
}