MCPcopy Create free account
hub / github.com/github/gh-aw / TestSelectJSONImportNameOverride

Function TestSelectJSONImportNameOverride

pkg/cli/fetch_json_naming_test.go:11–58  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestSelectJSONImportNameOverride(t *testing.T) {
12 t.Parallel()
13
14 tests := []struct {
15 name string
16 currentName string
17 workflow *JSONWorkflow
18 want string
19 }{
20 {
21 name: "uses json name when available, overrides current name",
22 currentName: "weekly-research",
23 workflow: &JSONWorkflow{
24 Name: "Workflow Title",
25 },
26 want: "workflow-title",
27 },
28 {
29 name: "uses json name when current name is guid",
30 currentName: "0be2cc4b-de12-43fe-ada7-55ef6dc8f3ba",
31 workflow: &JSONWorkflow{
32 Name: "Issue Triage",
33 },
34 want: "issue-triage",
35 },
36 {
37 name: "falls back to json title from extra when name missing",
38 currentName: "0be2cc4b-de12-43fe-ada7-55ef6dc8f3ba",
39 workflow: &JSONWorkflow{
40 Extra: map[string]any{"title": "Title From JSON"},
41 },
42 want: "title-from-json",
43 },
44 {
45 name: "keeps current name when no json name or title",
46 currentName: "0be2cc4b-de12-43fe-ada7-55ef6dc8f3ba",
47 workflow: &JSONWorkflow{},
48 want: "0be2cc4b-de12-43fe-ada7-55ef6dc8f3ba",
49 },
50 }
51
52 for _, tt := range tests {
53 t.Run(tt.name, func(t *testing.T) {
54 t.Parallel()
55 assert.Equal(t, tt.want, selectJSONImportNameOverride(tt.currentName, tt.workflow))
56 })
57 }
58}

Callers

nothing calls this directly

Calls 2

RunMethod · 0.45

Tested by

no test coverage detected