(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.NewMockConfig(), |
| 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.NewMockConfig(), |
| 110 | Hostname: "github.com", |
| 111 | Key: "editor", |
| 112 | Value: "vim", |
| 113 | }, |
| 114 | expectedValue: "vim", |
| 115 | }, |
| 116 | { |
| 117 | name: "set api_host scoped by host", |
| 118 | input: &SetOptions{ |
| 119 | Config: config.NewMockConfig(), |
| 120 | Hostname: "github.example.com", |
| 121 | Key: "api_host", |
| 122 | Value: "api-gateway.example.com", |
| 123 | }, |
| 124 | expectedValue: "api-gateway.example.com", |
| 125 | }, |
| 126 | { |
| 127 | name: "set api_host without hostname", |
| 128 | input: &SetOptions{ |
| 129 | Config: config.NewMockConfig(), |
| 130 | Key: "api_host", |
| 131 | Value: "api-gateway.example.com", |
| 132 | }, |
| 133 | wantsErr: true, |
| 134 | errMsg: "--host required when setting api_host", |
| 135 | }, |
| 136 | { |
| 137 | name: "set unknown key", |
| 138 | input: &SetOptions{ |
| 139 | Config: config.NewMockConfig(), |
| 140 | Key: "unknownKey", |
| 141 | Value: "someValue", |
| 142 | }, |
| 143 | expectedValue: "someValue", |
| 144 | stderr: "! warning: 'unknownKey' is not a known configuration key\n", |
nothing calls this directly
no test coverage detected