(t *testing.T)
| 153 | } |
| 154 | |
| 155 | func TestDefaultsValidateFile(t *testing.T) { |
| 156 | t.Run("accepts valid values", func(t *testing.T) { |
| 157 | err := defaultsValidateFile(&defaultsFile{ |
| 158 | DefaultMaxAICredits: new("1000"), |
| 159 | DefaultMaxTurnCacheMisses: new("5"), |
| 160 | DefaultDetectionMaxAICredits: new("400"), |
| 161 | DefaultMaxDailyAICredits: new("500000"), |
| 162 | DefaultMaxTurns: new("12"), |
| 163 | DefaultTimeoutMinutes: new("30"), |
| 164 | DefaultDetectionModel: new("claude-sonnet-4.6"), |
| 165 | DefaultUTC: new("-08:00"), |
| 166 | DefaultModelCopilot: new("gpt-5-mini"), |
| 167 | DefaultModelClaude: new("claude-haiku-4.5"), |
| 168 | DefaultModelCodex: new("gpt-5.4-mini"), |
| 169 | }) |
| 170 | require.NoError(t, err) |
| 171 | }) |
| 172 | |
| 173 | t.Run("accepts -1 to disable detection budget steering", func(t *testing.T) { |
| 174 | err := defaultsValidateFile(&defaultsFile{ |
| 175 | DefaultDetectionMaxAICredits: new("-1"), |
| 176 | }) |
| 177 | require.NoError(t, err) |
| 178 | }) |
| 179 | |
| 180 | t.Run("rejects invalid numeric and empty model values", func(t *testing.T) { |
| 181 | err := defaultsValidateFile(&defaultsFile{ |
| 182 | DefaultMaxAICredits: new("0"), |
| 183 | DefaultMaxTurnCacheMisses: new("0"), |
| 184 | DefaultDetectionMaxAICredits: new("0"), |
| 185 | DefaultMaxDailyAICredits: new("0"), |
| 186 | DefaultMaxTurns: new("abc"), |
| 187 | DefaultTimeoutMinutes: new("0"), |
| 188 | DefaultUTC: new("west"), |
| 189 | DefaultModelCopilot: new(" "), |
| 190 | }) |
| 191 | require.Error(t, err) |
| 192 | assert.Contains(t, err.Error(), "default_max_ai_credits must be a non-zero integer when set") |
| 193 | assert.Contains(t, err.Error(), "default_max_turn_cache_misses must be a positive integer when set") |
| 194 | assert.Contains(t, err.Error(), "default_detection_max_ai_credits must be a non-zero integer when set") |
| 195 | assert.Contains(t, err.Error(), "default_max_daily_ai_credits must be a non-zero integer when set") |
| 196 | assert.Contains(t, err.Error(), "default_max_turns must be a positive integer when set") |
| 197 | assert.Contains(t, err.Error(), "default_timeout_minutes must be a positive integer when set") |
| 198 | assert.Contains(t, err.Error(), "default_utc must be a numeric UTC offset") |
| 199 | assert.Contains(t, err.Error(), "default_model_copilot cannot be empty when set") |
| 200 | }) |
| 201 | } |
| 202 | |
| 203 | func TestDefaultsTargetEndpoints(t *testing.T) { |
| 204 | repoTarget := defaultsTarget{scope: defaultsScopeRepo, repoOwner: "github", repoName: "gh-aw"} |
nothing calls this directly
no test coverage detected