2024-11-16 20:11:24 -08:00
|
|
|
//
|
|
|
|
// Copyright © 2024 Salar Rahmanian.
|
2025-02-09 10:34:15 -08:00
|
|
|
//
|
2024-11-16 20:11:24 -08:00
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
2025-02-09 10:34:15 -08:00
|
|
|
//
|
2024-11-16 20:11:24 -08:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2025-02-09 10:34:15 -08:00
|
|
|
//
|
2024-11-16 20:11:24 -08:00
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import Testing
|
2025-02-09 10:34:15 -08:00
|
|
|
|
2024-11-16 20:11:24 -08:00
|
|
|
@testable import Fishee
|
|
|
|
|
|
|
|
@Suite
|
|
|
|
final class FisheeTests {
|
2025-02-09 10:34:15 -08:00
|
|
|
@Test func DryRunTest() {
|
|
|
|
do {
|
|
|
|
let help = try #require(Fishee.parse(["--dry-run"]) as Fishee)
|
|
|
|
#expect(help.dryRun)
|
|
|
|
} catch {
|
|
|
|
Issue.record("Test failed! \(error)")
|
2024-11-16 20:11:24 -08:00
|
|
|
}
|
2025-02-09 10:34:15 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test func HistoryFileTest() {
|
|
|
|
do {
|
|
|
|
let help = try #require(Fishee.parse(["--history-file", "/tmp/fishtest.txt"]) as Fishee)
|
|
|
|
#expect(help.fishHistoryLocationStr == "/tmp/fishtest.txt")
|
|
|
|
} catch {
|
|
|
|
Issue.record("Test failed! \(error)")
|
2024-11-16 20:11:24 -08:00
|
|
|
}
|
2025-02-09 10:34:15 -08:00
|
|
|
}
|
2024-11-16 20:11:24 -08:00
|
|
|
|
2025-02-09 10:34:15 -08:00
|
|
|
@Test func OutputFileTest() {
|
|
|
|
do {
|
|
|
|
let help = try #require(Fishee.parse(["--output-file", "/tmp/fishtest.txt"]) as Fishee)
|
|
|
|
#expect(help.writeFileStr == "/tmp/fishtest.txt")
|
|
|
|
} catch {
|
|
|
|
Issue.record("Test failed! \(error)")
|
2024-11-16 20:11:24 -08:00
|
|
|
}
|
2025-02-09 10:34:15 -08:00
|
|
|
}
|
2024-11-16 20:11:24 -08:00
|
|
|
|
2025-02-09 10:34:15 -08:00
|
|
|
@Test func RemoveDuplicatesTest() {
|
|
|
|
do {
|
|
|
|
let help = try #require(Fishee.parse(["--remove-duplicates"]) as Fishee)
|
|
|
|
#expect(help.removeDuplicates)
|
|
|
|
} catch {
|
|
|
|
Issue.record("Test failed! \(error)")
|
2024-11-16 20:11:24 -08:00
|
|
|
}
|
2025-02-09 10:34:15 -08:00
|
|
|
}
|
2024-11-16 20:11:24 -08:00
|
|
|
|
2025-02-09 10:34:15 -08:00
|
|
|
@Test func BackupTest() {
|
|
|
|
do {
|
|
|
|
let help = try #require(Fishee.parse(["--backup"]) as Fishee)
|
|
|
|
#expect(help.backup)
|
|
|
|
} catch {
|
|
|
|
Issue.record("Test failed! \(error)")
|
2024-11-16 20:11:24 -08:00
|
|
|
}
|
2025-02-09 10:34:15 -08:00
|
|
|
}
|
2024-11-16 20:11:24 -08:00
|
|
|
|
2025-02-09 10:34:15 -08:00
|
|
|
@Test func NoBackupTest() {
|
|
|
|
do {
|
|
|
|
let help = try #require(Fishee.parse(["--no-backup"]) as Fishee)
|
|
|
|
#expect(!help.backup)
|
|
|
|
} catch {
|
|
|
|
Issue.record("Test failed! \(error)")
|
2024-11-16 20:11:24 -08:00
|
|
|
}
|
2025-02-09 10:34:15 -08:00
|
|
|
}
|
2024-11-16 20:11:24 -08:00
|
|
|
}
|