import Testing
import Foundation
@testable import 康康

struct ModelManifestTests {

    @Test func llmHasNineFunctionalFiles() {
        #expect(ModelManifest.files(for: .llm).count == 9)
    }

    @Test func vlHasFourteenFunctionalFiles() {
        #expect(ModelManifest.files(for: .vl).count == 14)
    }

    @Test func llmTotalBytesMatchesManifest() {
        #expect(ModelManifest.totalBytes(for: .llm) == 984_013_244)
    }

    @Test func vlTotalBytesMatchesManifest() {
        #expect(ModelManifest.totalBytes(for: .vl) == 3_109_729_929)
    }

    @Test func excludesReadmeAndGitattributes() {
        for kind in [ModelKind.llm, .vl] {
            let names = ModelManifest.files(for: kind).map(\.path)
            #expect(!names.contains("README.md"))
            #expect(!names.contains(".gitattributes"))
        }
    }

    @Test func includesEssentialFiles() {
        let llm = ModelManifest.files(for: .llm).map(\.path)
        #expect(llm.contains("config.json"))
        #expect(llm.contains("model.safetensors"))
        #expect(llm.contains("tokenizer.json"))

        let vl = ModelManifest.files(for: .vl).map(\.path)
        #expect(vl.contains("preprocessor_config.json"))  // VL 拍照识别必需
        #expect(vl.contains("model.safetensors"))
    }

    @Test func fileURLIsBaseSlashRepoSlashPath() {
        let file = ModelFile(path: "config.json", bytes: 937)
        let url = ModelManifest.fileURL(for: .llm, file: file)
        #expect(url.absoluteString == "https://file.myv0.com/Qwen3-1.7B-4bit/config.json")
    }
}
