(t *testing.T)
| 100 | } |
| 101 | |
| 102 | func TestShouldUseExpiring(t *testing.T) { |
| 103 | tests := []struct { |
| 104 | name string |
| 105 | configured string |
| 106 | flagValue *bool |
| 107 | want bool |
| 108 | }{ |
| 109 | { |
| 110 | name: "disabled by default", |
| 111 | want: false, |
| 112 | }, |
| 113 | { |
| 114 | name: "enabled by configuration", |
| 115 | configured: "enabled", |
| 116 | want: true, |
| 117 | }, |
| 118 | { |
| 119 | name: "explicit flag enables disabled configuration", |
| 120 | configured: "disabled", |
| 121 | flagValue: new(true), |
| 122 | want: true, |
| 123 | }, |
| 124 | { |
| 125 | name: "explicit flag disables enabled configuration", |
| 126 | configured: "enabled", |
| 127 | flagValue: new(false), |
| 128 | want: false, |
| 129 | }, |
| 130 | { |
| 131 | name: "explicit flag and configuration both prefer expiring", |
| 132 | configured: "enabled", |
| 133 | flagValue: new(true), |
| 134 | want: true, |
| 135 | }, |
| 136 | { |
| 137 | name: "explicit flag and configuration both disable expiring", |
| 138 | configured: "disabled", |
| 139 | flagValue: new(false), |
| 140 | want: false, |
| 141 | }, |
| 142 | } |
| 143 | |
| 144 | for _, tt := range tests { |
| 145 | t.Run(tt.name, func(t *testing.T) { |
| 146 | cfg := config.NewMockConfig() |
| 147 | if tt.configured != "" { |
| 148 | cfg.Set("github.com", "expiring_credentials", tt.configured) |
| 149 | } |
| 150 | |
| 151 | require.Equal(t, tt.want, ShouldUseExpiring(cfg, tt.flagValue, "github.com")) |
| 152 | }) |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | func TestLogin(t *testing.T) { |
| 157 | tests := []struct { |
nothing calls this directly
no test coverage detected