샘플
github.com/frankban/quicktest v1.14.6: ErrorMatches
검증된 샘플 — golang github.com/frankban/quicktest v1.14.6: ErrorMatches. go 1.26 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다.
sha256:00cfc17994d152777e9b67bf0433a2e134aabcb3d502ab74e8eceb37cb1f8c4f
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 go
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| go 1.26 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · golang@1golang:1.26@sha256:e30143be198a… |
2026-09-06 |
케이스
HOW- 목표
- verify github.com/frankban/quicktest.ErrorMatches in pkg:golang/github.com/frankban/quicktest@v1.14.6
- 심벌
-
- github.com/frankban/quicktest.ErrorMatches
- 생성일
- 2026-09-06T18:32:07Z
컨트랙트
- qt.ErrorMatches verifies that an error message matches a regular expression pattern string
- qt.ErrorMatches verifies that an error message matches a precompiled *regexp.Regexp pattern
- qt.ErrorMatches reports failure when an error message does not match the regular expression pattern
- qt.ErrorMatches reports bad check failure when the value under test is nil or not an error
- qt.ErrorMatches reports bad check failure when the pattern is an invalid regular expression syntax
- qt.ErrorMatches reports bad check failure when the pattern is neither a string nor a *regexp.Regexp
파일
- PROMPT.md
- contract_test.go
- csx.json
- go.mod
- go.sum
- spec.json
소스
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify github.com/frankban/quicktest.ErrorMatches in pkg:golang/github.com/frankban/quicktest@v1.14.6
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:golang/github.com/frankban/quicktest@v1.14.6
Demonstrate these symbols/APIs:
- github.com/frankban/quicktest.ErrorMatches
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
package sample_test
import (
"errors"
"fmt"
"regexp"
"strings"
"testing"
qt "github.com/frankban/quicktest"
)
// tbSpy embeds testing.TB to capture Error and Fatal calls without terminating test execution.
type tbSpy struct {
testing.TB
failed bool
fataled bool
errorBuf strings.Builder
fatalBuf strings.Builder
}
func (s *tbSpy) Helper() {}
func (s *tbSpy) Error(args ...interface{}) {
s.failed = true
s.errorBuf.WriteString(fmt.Sprint(args...))
}
func (s *tbSpy) Fatal(args ...interface{}) {
s.failed = true
s.fataled = true
s.fatalBuf.WriteString(fmt.Sprint(args...))
}
// Contract 1: qt.ErrorMatches verifies that an error message matches a regular expression pattern string
func TestErrorMatchesStringPattern(t *testing.T) {
c := qt.New(t)
err := errors.New("request failed: timeout after 5s")
// Full match with pattern passes
c.Assert(err, qt.ErrorMatches, "request failed: timeout after .*")
// Unanchored partial substring match fails due to full-string anchoring in ErrorMatches
spy := &tbSpy{TB: t}
cSpy := qt.New(spy)
ok := cSpy.Check(err, qt.ErrorMatches, "timeout")
if ok || !spy.failed {
t.Fatal("expected unanchored substring to fail string pattern check")
}
}
// Contract 2: qt.ErrorMatches verifies that an error message matches a precompiled *regexp.Regexp pattern
func TestErrorMatchesRegexpPattern(t *testing.T) {
c := qt.New(t)
err := errors.New("HTTP 404: resource not found")
pattern := regexp.MustCompile(`HTTP \d{3}: resource not found`)
c.Assert(err, qt.ErrorMatches, pattern)
}
// Contract 3: qt.ErrorMatches reports failure when an error message does not match the regular expression pattern
func TestErrorMatchesMismatch(t *testing.T) {
spy := &tbSpy{TB: t}
c := qt.New(spy)
err := errors.New("connection reset by peer")
ok := c.Check(err, qt.ErrorMatches, "permission denied")
if ok {
t.Fatal("expected Check to return false on mismatched pattern")
}
if !spy.failed {
t.Fatal("expected TB.Error to be called on assertion failure")
}
out := spy.errorBuf.String()
if !strings.Contains(out, "error does not match regexp") {
t.Fatalf("expected failure output to state 'error does not match regexp', got: %s", out)
}
}
// Contract 4: qt.ErrorMatches reports bad check failure when the value under test is nil or not an error
func TestErrorMatchesNonError(t *testing.T) {
spy := &tbSpy{TB: t}
c := qt.New(spy)
// nil error value
ok := c.Check(nil, qt.ErrorMatches, "some error")
if ok {
t.Fatal("expected Check to fail for nil error")
}
if !strings.Contains(spy.errorBuf.String(), "got nil error but want non-nil") {
t.Fatalf("expected nil error diagnostic, got: %s", spy.errorBuf.String())
}
// non-error type (string)
spy.errorBuf.Reset()
spy.failed = false
ok = c.Check("not an error", qt.ErrorMatches, "not an error")
if ok {
t.Fatal("expected Check to fail when got is not an error type")
}
if !strings.Contains(spy.errorBuf.String(), "first argument is not an error") {
t.Fatalf("expected 'first argument is not an error' diagnostic, got: %s", spy.errorBuf.String())
}
}
// Contract 5: qt.ErrorMatches reports bad check failure when the pattern is an invalid regular expression syntax
func TestErrorMatchesInvalidRegexSyntax(t *testing.T) {
spy := &tbSpy{TB: t}
c := qt.New(spy)
err := errors.New("test error")
ok := c.Check(err, qt.ErrorMatches, "[invalid regex(")
if ok {
t.Fatal("expected Check to fail on invalid regex syntax")
}
out := spy.errorBuf.String()
if !strings.Contains(out, "cannot compile regexp") {
t.Fatalf("expected 'cannot compile regexp' error diagnostic, got: %s", out)
}
}
// Contract 6: qt.ErrorMatches reports bad check failure when the pattern is neither a string nor a *regexp.Regexp
func TestErrorMatchesInvalidPatternType(t *testing.T) {
spy := &tbSpy{TB: t}
c := qt.New(spy)
err := errors.New("test error")
ok := c.Check(err, qt.ErrorMatches, 12345)
if ok {
t.Fatal("expected Check to fail when pattern is an integer")
}
out := spy.errorBuf.String()
if !strings.Contains(out, "regexp is not a string") {
t.Fatalf("expected 'regexp is not a string' error diagnostic, got: %s", out)
}
}
{"case":{"caseId":"case:sha256:88148b8a9824d1f2e52a255fa809808901b92050f968cebc5c50766086d16902","contract":["qt.ErrorMatches verifies that an error message matches a regular expression pattern string","qt.ErrorMatches verifies that an error message matches a precompiled *regexp.Regexp pattern","qt.ErrorMatches reports failure when an error message does not match the regular expression pattern","qt.ErrorMatches reports bad check failure when the value under test is nil or not an error","qt.ErrorMatches reports bad check failure when the pattern is an invalid regular expression syntax","qt.ErrorMatches reports bad check failure when the pattern is neither a string nor a *regexp.Regexp"],"goal":"verify github.com/frankban/quicktest.ErrorMatches in pkg:golang/github.com/frankban/quicktest@v1.14.6","kind":"HOW","packages":["pkg:golang/github.com/frankban/quicktest@v1.14.6"],"schemaVersion":1,"symbols":["github.com/frankban/quicktest.ErrorMatches"]},"contractCommand":["go","test","-v","./..."],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"golang","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"go","schemaVersion":1},"license":"MIT-0","packages":["pkg:golang/github.com/frankban/quicktest@v1.14.6"],"schemaVersion":1,"subject":"pkg:golang/github.com/frankban/quicktest@v1.14.6","symbols":["github.com/frankban/quicktest.ErrorMatches"],"verifierAdapter":"golang@1"}
module sample
go 1.26.6
require github.com/frankban/quicktest v1.14.6
require (
github.com/google/go-cmp v0.5.9 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
)
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
{
"schemaVersion": 1,
"goal": "verify github.com/frankban/quicktest.ErrorMatches in pkg:golang/github.com/frankban/quicktest@v1.14.6",
"kind": "HOW",
"packages": [
"pkg:golang/github.com/frankban/quicktest@v1.14.6"
],
"symbols": [
"github.com/frankban/quicktest.ErrorMatches"
]
}
오리진 시더
익명