Add JSON input (#3)
All checks were successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/all-checks-complete Pipeline was successful

Co-authored-by: Smaug123 <patrick+github@patrickstevens.co.uk>
Reviewed-on: #3
This commit is contained in:
2023-09-08 18:19:06 +00:00
parent 1b1c902667
commit 3e3d092c27
35 changed files with 1407 additions and 113 deletions

View File

@@ -0,0 +1,30 @@
namespace AnkiStatic.Test
open AnkiStatic
open NUnit.Framework
open System
open System.IO
[<TestFixture>]
module TestEndToEnd =
type private Dummy =
class
end
[<TestCase "example1.json">]
let ``End-to-end test of example1.json`` (fileName : string) =
let assembly = typeof<Dummy>.Assembly
let json = Utils.readResource assembly fileName
let collection, notes = JsonCollection.deserialise json |> JsonCollection.toInternal
let outputFile =
Path.GetTempFileName ()
|> fun f -> Path.ChangeExtension (f, ".apkg")
|> FileInfo
let collection = SerialisedCollection.toSqlite collection
Sqlite.writeAll (Random 1) collection notes outputFile |> fun t -> t.Result
Console.WriteLine $"Written file: %s{outputFile.FullName}"