|
| 1 | +import CodexBarCore |
| 2 | +import Testing |
| 3 | + |
| 4 | +struct ProviderLabelMetadataCharacterizationTests { |
| 5 | + // MARK: - Label non-empty constraints |
| 6 | + |
| 7 | + @Test |
| 8 | + func `displayName is non-empty for all providers`() { |
| 9 | + for descriptor in ProviderDescriptorRegistry.all { |
| 10 | + #expect( |
| 11 | + !descriptor.metadata.displayName.isEmpty, |
| 12 | + "Provider \(descriptor.id.rawValue) has empty displayName.") |
| 13 | + } |
| 14 | + } |
| 15 | + |
| 16 | + @Test |
| 17 | + func `sessionLabel is non-empty for all providers`() { |
| 18 | + for descriptor in ProviderDescriptorRegistry.all { |
| 19 | + #expect( |
| 20 | + !descriptor.metadata.sessionLabel.isEmpty, |
| 21 | + "Provider \(descriptor.id.rawValue) has empty sessionLabel.") |
| 22 | + } |
| 23 | + } |
| 24 | + |
| 25 | + // MARK: - Known empty weeklyLabel exceptions |
| 26 | + |
| 27 | + @Test |
| 28 | + func `weeklyLabel empty providers are explicitly characterized`() { |
| 29 | + // Allowlist of providers known to have empty weeklyLabel on current main. |
| 30 | + // If a new provider is added with empty weeklyLabel, this test fails and |
| 31 | + // requires a deliberate decision to add it here — preventing silent regressions. |
| 32 | + let knownEmptyWeeklyLabelProviders: Set<UsageProvider> = [.mistral] |
| 33 | + for descriptor in ProviderDescriptorRegistry.all where descriptor.metadata.weeklyLabel.isEmpty { |
| 34 | + #expect( |
| 35 | + knownEmptyWeeklyLabelProviders.contains(descriptor.id), |
| 36 | + "Provider \(descriptor.id.rawValue) has empty weeklyLabel and is not in the known exception list.") |
| 37 | + } |
| 38 | + } |
| 39 | + |
| 40 | + // MARK: - Invariant: supportsOpus implies opusLabel |
| 41 | + |
| 42 | + @Test |
| 43 | + func `supportsOpus providers declare non-empty opusLabel`() { |
| 44 | + for descriptor in ProviderDescriptorRegistry.all where descriptor.metadata.supportsOpus { |
| 45 | + #expect( |
| 46 | + descriptor.metadata.opusLabel != nil && !descriptor.metadata.opusLabel!.isEmpty, |
| 47 | + "Provider \(descriptor.id.rawValue) has supportsOpus=true but opusLabel is nil or empty.") |
| 48 | + } |
| 49 | + } |
| 50 | + |
| 51 | + // MARK: - opusLabel structural constraint |
| 52 | + |
| 53 | + @Test |
| 54 | + func `opusLabel is nil or non-empty`() { |
| 55 | + for descriptor in ProviderDescriptorRegistry.all { |
| 56 | + if let opusLabel = descriptor.metadata.opusLabel { |
| 57 | + #expect( |
| 58 | + !opusLabel.isEmpty, |
| 59 | + "Provider \(descriptor.id.rawValue) has empty opusLabel string instead of nil.") |
| 60 | + } |
| 61 | + } |
| 62 | + } |
| 63 | +} |
0 commit comments