MCPcopy Create free account
hub / github.com/cli/cli / TestExportVariables

Function TestExportVariables

pkg/cmd/variable/get/get_test.go:300–318  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

298}
299
300func TestExportVariables(t *testing.T) {
301 ios, _, stdout, _ := iostreams.Test()
302 tf, _ := time.Parse(time.RFC3339, "2024-01-01T00:00:00Z")
303 vs := &shared.Variable{
304 Name: "v1",
305 Value: "test1",
306 UpdatedAt: tf,
307 CreatedAt: tf,
308 Visibility: shared.All,
309 SelectedReposURL: "https://someurl.com",
310 NumSelectedRepos: 1,
311 }
312 exporter := cmdutil.NewJSONExporter()
313 exporter.SetFields(shared.VariableJSONFields)
314 require.NoError(t, exporter.Write(ios, vs))
315 require.JSONEq(t,
316 `{"name":"v1","numSelectedRepos":1,"selectedReposURL":"https://someurl.com","updatedAt":"2024-01-01T00:00:00Z","createdAt":"2024-01-01T00:00:00Z","value":"test1","visibility":"all"}`,
317 stdout.String())
318}

Callers

nothing calls this directly

Calls 5

TestFunction · 0.92
NewJSONExporterFunction · 0.92
SetFieldsMethod · 0.80
WriteMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected