(t *testing.T)
| 103 | } |
| 104 | |
| 105 | func TestGithubRateLimits(t *testing.T) { |
| 106 | t.Parallel() |
| 107 | |
| 108 | now := time.Now() |
| 109 | cases := []struct { |
| 110 | Name string |
| 111 | NoHeaders bool |
| 112 | Omit []string |
| 113 | ExpectNoMetrics bool |
| 114 | Limit int |
| 115 | Remaining int |
| 116 | Used int |
| 117 | Reset time.Time |
| 118 | |
| 119 | at time.Time |
| 120 | }{ |
| 121 | { |
| 122 | Name: "NoHeaders", |
| 123 | NoHeaders: true, |
| 124 | ExpectNoMetrics: true, |
| 125 | }, |
| 126 | { |
| 127 | Name: "ZeroHeaders", |
| 128 | ExpectNoMetrics: true, |
| 129 | }, |
| 130 | { |
| 131 | Name: "OverLimit", |
| 132 | Limit: 100, |
| 133 | Remaining: 0, |
| 134 | Used: 500, |
| 135 | Reset: now.Add(time.Hour), |
| 136 | at: now, |
| 137 | }, |
| 138 | { |
| 139 | Name: "UnderLimit", |
| 140 | Limit: 100, |
| 141 | Remaining: 0, |
| 142 | Used: 500, |
| 143 | Reset: now.Add(time.Hour), |
| 144 | at: now, |
| 145 | }, |
| 146 | { |
| 147 | Name: "Partial", |
| 148 | Omit: []string{"x-ratelimit-remaining"}, |
| 149 | ExpectNoMetrics: true, |
| 150 | Limit: 100, |
| 151 | Remaining: 0, |
| 152 | Used: 500, |
| 153 | Reset: now.Add(time.Hour), |
| 154 | at: now, |
| 155 | }, |
| 156 | } |
| 157 | |
| 158 | for _, c := range cases { |
| 159 | t.Run(c.Name, func(t *testing.T) { |
| 160 | t.Parallel() |
| 161 | |
| 162 | reg := prometheus.NewRegistry() |
nothing calls this directly
no test coverage detected