(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func 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 | } |
nothing calls this directly
no test coverage detected