MCPcopy Index your code
hub / github.com/cli/cli / TestRepositoryExportData

Function TestRepositoryExportData

pkg/search/result_test.go:97–129  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

95}
96
97func 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
131func TestIssueExportData(t *testing.T) {
132 var updatedAt = time.Date(2021, 2, 28, 12, 30, 0, 0, time.UTC)

Callers

nothing calls this directly

Calls 4

EqualMethod · 0.80
RunMethod · 0.65
ExportDataMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected