(t *testing.T)
| 905 | } |
| 906 | |
| 907 | func 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 |
| 917 | Success |
| 918 | ##[endgroup] |
| 919 | ##[group]Step 2 |
| 920 | Running... |
| 921 | ##[error]Something went wrong |
| 922 | Error details here |
| 923 | ##[endgroup] |
| 924 | ##[group]Step 3 |
| 925 | This 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 |
| 937 | Success |
| 938 | ##[endgroup] |
| 939 | ##[group]Step 2 |
| 940 | Running command... |
| 941 | exit 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 |
| 953 | Success |
| 954 | ##[endgroup] |
| 955 | ##[group]Step 2 |
| 956 | Also 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) { |
nothing calls this directly
no test coverage detected