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

Function TestExportVariables

pkg/cmd/variable/list/list_test.go:447–465  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

445}
446
447func TestExportVariables(t *testing.T) {
448 ios, _, stdout, _ := iostreams.Test()
449 tf, _ := time.Parse(time.RFC3339, "2024-01-01T00:00:00Z")
450 vs := []shared.Variable{{
451 Name: "v1",
452 Value: "test1",
453 UpdatedAt: tf,
454 CreatedAt: tf,
455 Visibility: shared.All,
456 SelectedReposURL: "https://someurl.com",
457 NumSelectedRepos: 1,
458 }}
459 exporter := cmdutil.NewJSONExporter()
460 exporter.SetFields(shared.VariableJSONFields)
461 require.NoError(t, exporter.Write(ios, vs))
462 require.JSONEq(t,
463 `[{"name":"v1","numSelectedRepos":1,"selectedReposURL":"https://someurl.com","updatedAt":"2024-01-01T00:00:00Z","createdAt":"2024-01-01T00:00:00Z","value":"test1","visibility":"all"}]`,
464 stdout.String())
465}

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