Files
oai-swift/oAITests/GitignoreParserTests.swift
rune 76b58e6fdc Rename app from oAI to Confab
"oAI" reads as easily confused with OpenAI, both visually and in
casual conversation. Renamed to "Confab" throughout: Xcode
target/scheme/bundle ID (com.oai.Confab), Info.plist and Help Book
identity, all user-facing UI text, internal Log subsystem and color
identifiers, localization catalogs (6 languages, including a proper
reworded/retranslated Intel-deprecation notice), Help Book HTML
content, and docs (README/DEVELOPMENT/PRIVACY/SECURITY).

Deliberately cosmetic-only: the on-disk data folder
(~/Library/Application Support/oAI/), database/backup filenames,
Keychain service identifiers, and EncryptionService's key-derivation
inputs are all left untouched so existing conversations, settings,
and stored API keys survive the update with zero migration and no
re-entering credentials. Verified live: a real signed build
successfully decrypted a stored API key and loaded an existing
conversation database after the bundle ID change.

Also includes a small already-completed, previously uncommitted
model-release-date feature (ModelInfo/OpenRouterModels/
OpenRouterProvider/ModelInfoView) that happened to share several
files with this rename.

Gitignored on this branch and updated on disk but not part of this
commit: CLAUDE.md, RELEASE_NOTES.md, and the build*.sh scripts.
2026-08-02 14:58:14 +02:00

84 lines
2.7 KiB
Swift

//
// GitignoreParserTests.swift
// oAITests
//
// SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0
// Copyright (C) 2026 Rune Olsen
import Testing
@testable import Confab
@Suite("GitignoreParser")
struct GitignoreParserTests {
private func parser(for content: String) -> GitignoreParser {
var parser = GitignoreParser(rootPath: "/tmp/fake-root")
parser.parseContent(content)
return parser
}
@Test("Simple extension wildcard matches at any depth")
func extensionWildcard() {
let p = parser(for: "*.log")
#expect(p.isIgnored("debug.log"))
#expect(p.isIgnored("nested/debug.log"))
#expect(!p.isIgnored("debug.txt"))
}
@Test("Directory pattern matches the directory and everything under it")
func directoryPattern() {
let p = parser(for: "build/")
#expect(p.isIgnored("build"))
#expect(p.isIgnored("build/output.txt"))
#expect(p.isIgnored("foo/build/output.txt"))
#expect(!p.isIgnored("rebuild"))
}
@Test("Path-anchored pattern only matches that exact relative path, not nested occurrences")
func pathAnchoredWildcard() {
let p = parser(for: "src/*.tmp")
#expect(p.isIgnored("src/foo.tmp"))
#expect(!p.isIgnored("other/src/foo.tmp"))
#expect(!p.isIgnored("src/sub/foo.tmp"))
}
@Test("Double-star matches across any number of intermediate directories")
func doubleStarPattern() {
let p = parser(for: "**/logs")
#expect(p.isIgnored("logs"))
#expect(p.isIgnored("a/logs"))
#expect(p.isIgnored("a/b/logs"))
#expect(p.isIgnored("a/logs/file.txt"))
#expect(!p.isIgnored("logsfile"))
}
@Test("Negation un-ignores a path matched by an earlier rule")
func negation() {
let p = parser(for: "*.log\n!important.log")
#expect(p.isIgnored("debug.log"))
#expect(!p.isIgnored("important.log"))
}
@Test("Comments and blank lines are skipped, not treated as patterns")
func commentsAndBlankLines() {
let p = parser(for: "# a comment\n\n*.log\n \n")
#expect(p.isIgnored("x.log"))
#expect(!p.isIgnored("# a comment"))
}
@Test("Leading slash still matches (root-anchoring is not enforced by this implementation)")
func leadingSlashPattern() {
// Documents actual current behavior: the leading "/" is stripped without
// truly restricting the match to the root level, unlike real git.
let p = parser(for: "/dist")
#expect(p.isIgnored("dist"))
#expect(p.isIgnored("dist/file.txt"))
}
@Test("No rules means nothing is ignored")
func noRules() {
let p = parser(for: "")
#expect(!p.isIgnored("anything.txt"))
}
}