(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func TestArtifactExportData(t *testing.T) { |
| 13 | createdAt := time.Date(2026, 9, 21, 23, 0, 0, 0, time.UTC) |
| 14 | updatedAt := time.Date(2026, 9, 24, 21, 0, 0, 0, time.UTC) |
| 15 | |
| 16 | full := Artifact{ |
| 17 | ID: 6626, |
| 18 | Number: 2, |
| 19 | Type: "generic", |
| 20 | Name: "OAuth callback plan", |
| 21 | Body: "# OAuth callback plan", |
| 22 | BodyHTML: "<h1>OAuth callback plan</h1>", |
| 23 | Description: "Register the callback URL.", |
| 24 | Creator: &Actor{ID: 2, Login: "hubot"}, |
| 25 | UpdatedByActor: &Actor{ID: 1, Login: "monalisa"}, |
| 26 | CreatedAt: &createdAt, |
| 27 | UpdatedAt: &updatedAt, |
| 28 | URL: "https://github.com/monalisa/monas-cafe/issues/142/artifacts/2", |
| 29 | } |
| 30 | |
| 31 | tests := []struct { |
| 32 | name string |
| 33 | artifact Artifact |
| 34 | fields []string |
| 35 | wantJSON string |
| 36 | }{ |
| 37 | { |
| 38 | name: "every field", |
| 39 | artifact: full, |
| 40 | fields: ArtifactFields, |
| 41 | wantJSON: `{ |
| 42 | "body": "# OAuth callback plan", |
| 43 | "bodyHtml": "<h1>OAuth callback plan</h1>", |
| 44 | "createdAt": "2026-09-21T23:00:00Z", |
| 45 | "creator": {"id": 2, "login": "hubot"}, |
| 46 | "description": "Register the callback URL.", |
| 47 | "id": 6626, |
| 48 | "name": "OAuth callback plan", |
| 49 | "number": 2, |
| 50 | "type": "generic", |
| 51 | "updatedAt": "2026-09-24T21:00:00Z", |
| 52 | "updatedByActor": {"id": 1, "login": "monalisa"}, |
| 53 | "url": "https://github.com/monalisa/monas-cafe/issues/142/artifacts/2" |
| 54 | }`, |
| 55 | }, |
| 56 | { |
| 57 | name: "null users and timestamps stay null", |
| 58 | artifact: Artifact{ID: 6627, Number: 3, Type: "link", Name: "Staging OAuth runbook"}, |
| 59 | fields: []string{"creator", "updatedByActor", "createdAt", "updatedAt"}, |
| 60 | wantJSON: `{ |
| 61 | "createdAt": null, |
| 62 | "creator": null, |
| 63 | "updatedAt": null, |
| 64 | "updatedByActor": null |
| 65 | }`, |
| 66 | }, |
| 67 | { |
| 68 | name: "only the requested fields", |
| 69 | artifact: full, |
nothing calls this directly
no test coverage detected