(t *testing.T)
| 22 | ) |
| 23 | |
| 24 | func TestMergeRuntimeInputs(t *testing.T) { |
| 25 | testCases := []struct { |
| 26 | name string |
| 27 | with map[string]string |
| 28 | runtimeInputs map[string]string |
| 29 | want map[string]string |
| 30 | }{ |
| 31 | { |
| 32 | name: "no runtime inputs returns contract args unchanged", |
| 33 | with: map[string]string{"ignored_paths": "a,b"}, |
| 34 | runtimeInputs: nil, |
| 35 | want: map[string]string{"ignored_paths": "a,b"}, |
| 36 | }, |
| 37 | { |
| 38 | name: "runtime input on empty contract key", |
| 39 | with: map[string]string{}, |
| 40 | runtimeInputs: map[string]string{"ignored_paths": "c\nd"}, |
| 41 | want: map[string]string{"ignored_paths": "c\nd"}, |
| 42 | }, |
| 43 | { |
| 44 | name: "runtime input merges additively with contract value", |
| 45 | with: map[string]string{"ignored_paths": "a,b"}, |
| 46 | runtimeInputs: map[string]string{"ignored_paths": "c\nd"}, |
| 47 | want: map[string]string{"ignored_paths": "a,b\nc\nd"}, |
| 48 | }, |
| 49 | { |
| 50 | name: "runtime input on a different key is added alongside", |
| 51 | with: map[string]string{"paths": "**"}, |
| 52 | runtimeInputs: map[string]string{"ignored_paths": "c"}, |
| 53 | want: map[string]string{"paths": "**", "ignored_paths": "c"}, |
| 54 | }, |
| 55 | { |
| 56 | name: "empty contract value is replaced, not prefixed with newline", |
| 57 | with: map[string]string{"ignored_paths": ""}, |
| 58 | runtimeInputs: map[string]string{"ignored_paths": "c"}, |
| 59 | want: map[string]string{"ignored_paths": "c"}, |
| 60 | }, |
| 61 | } |
| 62 | |
| 63 | for _, tc := range testCases { |
| 64 | t.Run(tc.name, func(t *testing.T) { |
| 65 | got := MergeRuntimeInputs(tc.with, tc.runtimeInputs) |
| 66 | assert.Equal(t, tc.want, got) |
| 67 | }) |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | // TestMergeRuntimeInputsDoesNotMutate ensures the input maps are left untouched. |
| 72 | func TestMergeRuntimeInputsDoesNotMutate(t *testing.T) { |
nothing calls this directly
no test coverage detected