MCPcopy Create free account
hub / github.com/github/gh-aw / TestFindFirstFailingStep

Function TestFindFirstFailingStep

pkg/cli/audit_test.go:907–976  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

905}
906
907func TestFindFirstFailingStep(t *testing.T) {
908 tests := []struct {
909 name string
910 jobLog string
911 expectedStepNum int
912 checkOutput func(t *testing.T, output string)
913 }{
914 {
915 name: "Find failing step with error marker",
916 jobLog: `##[group]Step 1
917Success
918##[endgroup]
919##[group]Step 2
920Running...
921##[error]Something went wrong
922Error details here
923##[endgroup]
924##[group]Step 3
925This runs after failure
926##[endgroup]`,
927 expectedStepNum: 2,
928 checkOutput: func(t *testing.T, output string) {
929 if !strings.Contains(output, "##[error]Something went wrong") {
930 t.Error("Output should contain error message")
931 }
932 },
933 },
934 {
935 name: "Find failing step with exit code",
936 jobLog: `##[group]Step 1
937Success
938##[endgroup]
939##[group]Step 2
940Running command...
941exit code 1
942##[endgroup]`,
943 expectedStepNum: 2,
944 checkOutput: func(t *testing.T, output string) {
945 if !strings.Contains(output, "exit code 1") {
946 t.Error("Output should contain exit code")
947 }
948 },
949 },
950 {
951 name: "No failing steps",
952 jobLog: `##[group]Step 1
953Success
954##[endgroup]
955##[group]Step 2
956Also success
957##[endgroup]`,
958 expectedStepNum: 0,
959 checkOutput: nil,
960 },
961 }
962
963 for _, tt := range tests {
964 t.Run(tt.name, func(t *testing.T) {

Callers

nothing calls this directly

Calls 4

findFirstFailingStepFunction · 0.85
ErrorMethod · 0.45
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected