(t *testing.T)
| 96 | } |
| 97 | |
| 98 | func TestTaskErrorHelpers(t *testing.T) { |
| 99 | t.Parallel() |
| 100 | |
| 101 | wrapped := NewTaskValidationError(errors.New("bad input")) |
| 102 | if !errors.Is(wrapped, taskpkg.ErrValidation) { |
| 103 | t.Fatalf("NewTaskValidationError() = %v, want wrapped task validation sentinel", wrapped) |
| 104 | } |
| 105 | if got := NewTaskValidationError(nil); got != nil { |
| 106 | t.Fatalf("NewTaskValidationError(nil) = %v, want nil", got) |
| 107 | } |
| 108 | |
| 109 | tests := []struct { |
| 110 | name string |
| 111 | err error |
| 112 | want int |
| 113 | }{ |
| 114 | {name: "nil", err: nil, want: http.StatusOK}, |
| 115 | {name: "invalid scope", err: taskpkg.ErrInvalidScopeBinding, want: http.StatusBadRequest}, |
| 116 | {name: "immutable field", err: taskpkg.ErrImmutableField, want: http.StatusBadRequest}, |
| 117 | {name: "run missing", err: taskpkg.ErrTaskRunNotFound, want: http.StatusNotFound}, |
| 118 | {name: "session missing", err: session.ErrSessionNotFound, want: http.StatusNotFound}, |
| 119 | {name: "os not exist", err: os.ErrNotExist, want: http.StatusNotFound}, |
| 120 | {name: "workspace root missing", err: workspacepkg.ErrWorkspaceRootMissing, want: http.StatusGone}, |
| 121 | {name: "attach forbidden", err: taskpkg.ErrSessionAttachNotAllowed, want: http.StatusConflict}, |
| 122 | {name: "stale network channel", err: taskpkg.ErrStaleNetworkChannel, want: http.StatusConflict}, |
| 123 | {name: "default", err: errors.New("boom"), want: http.StatusInternalServerError}, |
| 124 | } |
| 125 | |
| 126 | for _, tt := range tests { |
| 127 | t.Run(tt.name, func(t *testing.T) { |
| 128 | t.Parallel() |
| 129 | if got := StatusForTaskError(tt.err); got != tt.want { |
| 130 | t.Fatalf("StatusForTaskError(%v) = %d, want %d", tt.err, got, tt.want) |
| 131 | } |
| 132 | }) |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | func TestAutomationAndNetworkErrorHelpers(t *testing.T) { |
| 137 | t.Parallel() |
nothing calls this directly
no test coverage detected