(t *testing.T)
| 95 | } |
| 96 | |
| 97 | func TestRepositoryExportData(t *testing.T) { |
| 98 | var createdAt = time.Date(2021, 2, 28, 12, 30, 0, 0, time.UTC) |
| 99 | tests := []struct { |
| 100 | name string |
| 101 | fields []string |
| 102 | repo Repository |
| 103 | output string |
| 104 | }{ |
| 105 | { |
| 106 | name: "exports requested fields", |
| 107 | fields: []string{"createdAt", "description", "fullName", "isArchived", "isFork", "isPrivate", "pushedAt"}, |
| 108 | repo: Repository{ |
| 109 | CreatedAt: createdAt, |
| 110 | Description: "description", |
| 111 | FullName: "cli/cli", |
| 112 | IsArchived: true, |
| 113 | IsFork: false, |
| 114 | IsPrivate: false, |
| 115 | PushedAt: createdAt, |
| 116 | }, |
| 117 | output: `{"createdAt":"2021-02-28T12:30:00Z","description":"description","fullName":"cli/cli","isArchived":true,"isFork":false,"isPrivate":false,"pushedAt":"2021-02-28T12:30:00Z"}`, |
| 118 | }, |
| 119 | } |
| 120 | for _, tt := range tests { |
| 121 | t.Run(tt.name, func(t *testing.T) { |
| 122 | exported := tt.repo.ExportData(tt.fields) |
| 123 | buf := bytes.Buffer{} |
| 124 | enc := json.NewEncoder(&buf) |
| 125 | require.NoError(t, enc.Encode(exported)) |
| 126 | assert.Equal(t, tt.output, strings.TrimSpace(buf.String())) |
| 127 | }) |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | func TestIssueExportData(t *testing.T) { |
| 132 | var updatedAt = time.Date(2021, 2, 28, 12, 30, 0, 0, time.UTC) |
nothing calls this directly
no test coverage detected