원클릭으로
go-unit-test
Style rules for writing Go unit tests. Load whenever writing or modifying *_test.go files.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Style rules for writing Go unit tests. Load whenever writing or modifying *_test.go files.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Create, edit, comment on, and label GitHub issues following the project's style
Implement gpsprot high-level (device-independent) configuration - the ConfigProtocol/Configurator - for a new GPS receiver protocol family
Build systematic collection of packet logs for a GPS receiver, covering all implemented decode paths per plan/packet-testing.md
Drive a test satpulsed instance from a recorded packet log, with no GPS hardware, by replaying the log through a FIFO with original packet pacing. Use to exercise the full scan/decode/event pipeline or the web interface from a capture.
End-to-end test of GPS message (gpsprot.*Msg) pipeline with GPS hardware
Stand up a throwaway satpulsed instance as an unprivileged user for testing, fed from a serial device or a FIFO. Use directly to run a test instance, or as the setup step for the drive-satpulsed-from-log and hardware-test-gps-msgs skills.
| name | go-unit-test |
| description | Style rules for writing Go unit tests. Load whenever writing or modifying *_test.go files. |
| allowed-tools | Bash, Glob, Grep, Read, Edit, Write |
Wherever practical, make tests table-driven and use reflect.DeepEqual to compare whole expected values rather than individual fields.
Use table-driven tests wherever possible. One table of test cases per test function.
Each test case struct should have fields for the inputs and the expected outputs.
A test case can have multiple input fields and multiple expected output fields.
Prefer expect as the prefix for expected-value fields (e.g. expect, expectErr).
func TestFoo(t *testing.T) {
tests := []struct {
name string
input InputType
expect OutputType
}{
{
name: "description of case",
input: InputType{...},
expect: OutputType{...},
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
got := Foo(tc.input)
if !reflect.DeepEqual(got, tc.expect) {
t.Errorf("got %+v\nwant %+v", got, tc.expect)
}
})
}
}
Do not compare struct fields individually. Put the complete expected value in the test table and compare the whole thing with reflect.DeepEqual.
Bad:
if got.X != 1 { t.Errorf(...) }
if got.Y != 2 { t.Errorf(...) }
Good:
if !reflect.DeepEqual(got, tc.expect) {
t.Errorf("got %+v\nwant %+v", got, tc.expect)
}
Use t.Fatalf for errors that prevent further testing (setup failures, parse errors).
Use t.Errorf for assertion failures (DeepEqual comparisons).
For tests that expect errors, add an expectErr bool field to the table:
if tc.expectErr {
if err == nil {
t.Fatalf("expected error")
}
return
}
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
Use only the standard testing package and reflect.DeepEqual. Do not use testify or other assertion libraries.