(t *testing.T)
| 85 | } |
| 86 | |
| 87 | func Test_setRun(t *testing.T) { |
| 88 | tests := []struct { |
| 89 | name string |
| 90 | input *SetOptions |
| 91 | expectedValue string |
| 92 | stdout string |
| 93 | stderr string |
| 94 | wantsErr bool |
| 95 | errMsg string |
| 96 | }{ |
| 97 | { |
| 98 | name: "set key value", |
| 99 | input: &SetOptions{ |
| 100 | Config: config.NewBlankConfig(), |
| 101 | Key: "editor", |
| 102 | Value: "vim", |
| 103 | }, |
| 104 | expectedValue: "vim", |
| 105 | }, |
| 106 | { |
| 107 | name: "set key value scoped by host", |
| 108 | input: &SetOptions{ |
| 109 | Config: config.NewBlankConfig(), |
| 110 | Hostname: "github.com", |
| 111 | Key: "editor", |
| 112 | Value: "vim", |
| 113 | }, |
| 114 | expectedValue: "vim", |
| 115 | }, |
| 116 | { |
| 117 | name: "set unknown key", |
| 118 | input: &SetOptions{ |
| 119 | Config: config.NewBlankConfig(), |
| 120 | Key: "unknownKey", |
| 121 | Value: "someValue", |
| 122 | }, |
| 123 | expectedValue: "someValue", |
| 124 | stderr: "! warning: 'unknownKey' is not a known configuration key\n", |
| 125 | }, |
| 126 | { |
| 127 | name: "set invalid value", |
| 128 | input: &SetOptions{ |
| 129 | Config: config.NewBlankConfig(), |
| 130 | Key: "git_protocol", |
| 131 | Value: "invalid", |
| 132 | }, |
| 133 | wantsErr: true, |
| 134 | errMsg: "failed to set \"git_protocol\" to \"invalid\": valid values are 'https', 'ssh'", |
| 135 | }, |
| 136 | } |
| 137 | for _, tt := range tests { |
| 138 | t.Run(tt.name, func(t *testing.T) { |
| 139 | _ = config.StubWriteConfig(t) |
| 140 | |
| 141 | ios, _, stdout, stderr := iostreams.Test() |
| 142 | tt.input.IO = ios |
| 143 | |
| 144 | err := setRun(tt.input) |
nothing calls this directly
no test coverage detected