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

Function TestExtractStepOutput

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

Source from the content-addressed store, hash-verified

828}
829
830func TestExtractStepOutput(t *testing.T) {
831 jobLog := `##[group]Run actions/checkout@v4
832Checking out repository...
833##[endgroup]
834##[group]Run ./setup-environment.sh
835Setting up environment...
836ENVIRONMENT=test
837##[endgroup]
838##[group]Run npm test
839Running tests...
840##[error]Test failed: expected 5, got 3
841Error: Process completed with exit code 1.
842##[endgroup]
843##[group]Run cleanup.sh
844Cleaning 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

Callers

nothing calls this directly

Calls 4

extractStepOutputFunction · 0.85
ErrorMethod · 0.45
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected