(t *testing.T)
| 828 | } |
| 829 | |
| 830 | func TestExtractStepOutput(t *testing.T) { |
| 831 | jobLog := `##[group]Run actions/checkout@v4 |
| 832 | Checking out repository... |
| 833 | ##[endgroup] |
| 834 | ##[group]Run ./setup-environment.sh |
| 835 | Setting up environment... |
| 836 | ENVIRONMENT=test |
| 837 | ##[endgroup] |
| 838 | ##[group]Run npm test |
| 839 | Running tests... |
| 840 | ##[error]Test failed: expected 5, got 3 |
| 841 | Error: Process completed with exit code 1. |
| 842 | ##[endgroup] |
| 843 | ##[group]Run cleanup.sh |
| 844 | Cleaning up... |
| 845 | ##[endgroup]` |
| 846 | |
| 847 | tests := []struct { |
| 848 | name string |
| 849 | stepNumber int |
| 850 | expectError bool |
| 851 | checkOutput func(t *testing.T, output string) |
| 852 | }{ |
| 853 | { |
| 854 | name: "Extract step 3 (failing step)", |
| 855 | stepNumber: 3, |
| 856 | expectError: false, |
| 857 | checkOutput: func(t *testing.T, output string) { |
| 858 | if !strings.Contains(output, "npm test") { |
| 859 | t.Error("Output should contain 'npm test'") |
| 860 | } |
| 861 | if !strings.Contains(output, "##[error]Test failed") { |
| 862 | t.Error("Output should contain error message") |
| 863 | } |
| 864 | }, |
| 865 | }, |
| 866 | { |
| 867 | name: "Extract step 1", |
| 868 | stepNumber: 1, |
| 869 | expectError: false, |
| 870 | checkOutput: func(t *testing.T, output string) { |
| 871 | if !strings.Contains(output, "actions/checkout") { |
| 872 | t.Error("Output should contain 'actions/checkout'") |
| 873 | } |
| 874 | }, |
| 875 | }, |
| 876 | { |
| 877 | name: "Extract non-existent step", |
| 878 | stepNumber: 99, |
| 879 | expectError: true, |
| 880 | checkOutput: nil, |
| 881 | }, |
| 882 | } |
| 883 | |
| 884 | for _, tt := range tests { |
| 885 | t.Run(tt.name, func(t *testing.T) { |
| 886 | output, err := extractStepOutput(jobLog, tt.stepNumber) |
| 887 |
nothing calls this directly
no test coverage detected