oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package personapi
2
3import (
4 "encoding/json"
5 "net/http/httptest"
6 "testing"
7)
8
9func TestPreviewErrorCopyKeys(t *testing.T) {
10 for _, tc := range []struct {
11 code, key string
12 status int
13 }{
14 {"preview_changed", "api.preview_changed", 409},
15 {"preview_expired", "api.preview_expired", 410},
16 } {
17 t.Run(tc.code, func(t *testing.T) {
18 w := httptest.NewRecorder()
19 WriteError(w, httptest.NewRequest("POST", "/api/v1/tasks/task/preview-pass", nil), tc.status, tc.code, nil)
20 var got Error
21 if err := json.Unmarshal(w.Body.Bytes(), &got); err != nil {
22 t.Fatal(err)
23 }
24 if w.Code != tc.status || got.Code != tc.code || got.CopyKey != tc.key {
25 t.Fatalf("preview error: status %d, %+v", w.Code, got)
26 }
27 })
28 }
29}
30