@@ -6,6 +6,7 @@ open Main.ArcVault
66open Main.ArcVaultHelper
77open Main.Bindings .Filesystem
88open Main.Bindings .Path
9+ open Main.Notes .NoteConstants
910open Swate.Components .Shared
1011open Vitest
1112
@@ -17,6 +18,11 @@ let private mkdirRecursiveAsync (directoryPath: string) = promise {
1718let private writeTextFileAsync ( filePath : string ) ( content : string ) =
1819 writeFileAsync filePath content TextEncoding.Utf8
1920
21+ let private arctrlDefaultGitignoreContent () =
22+ match ARCtrl.Contract.Git.gitignoreContract.DTO with
23+ | Some( ARCtrl.Contract.DTO.Text content) -> content
24+ | _ -> failwith " ARCtrl default .gitignore contract does not contain text content."
25+
2026let private addDataMapToAllEntityTypes ( arc : ARC ) =
2127 let study = ArcStudy( " Study With DataMap" )
2228 study.DataMap <- Some( DataMap.init ())
@@ -58,7 +64,7 @@ Vitest.describe (
5864 )
5965
6066 Vitest.test (
61- " Swate write contracts contain only targeted ARC files" ,
67+ " Swate write contracts contain only targeted scaffold and ARC files" ,
6268 fun () ->
6369 let arc = ARC( " TargetedWriteArc" )
6470 addDataMapToAllEntityTypes arc
@@ -77,11 +83,13 @@ Vitest.describe (
7783
7884 let expectedPaths =
7985 [|
86+ " .gitignore"
8087 " LICENSE"
8188 " assays/.gitkeep"
8289 " assays/Assay With DataMap/isa.assay.xlsx"
8390 " assays/Assay With DataMap/isa.datamap.xlsx"
8491 " isa.investigation.xlsx"
92+ " notes/README.md"
8593 " runs/.gitkeep"
8694 " runs/Run With DataMap/isa.datamap.xlsx"
8795 " runs/Run With DataMap/isa.run.xlsx"
@@ -97,6 +105,34 @@ Vitest.describe (
97105 Vitest.expect( actualPaths) .toEqual ( expectedPaths)
98106 )
99107
108+ Vitest.test (
109+ " TryWriteAsyncSwate writes the default gitignore and notes README into an ARC root" ,
110+ fun () -> promise {
111+ let! rootPath = TestHelpers.createTempDirectoryAsync " swate-default-gitignore-"
112+ let arcPath = join [| rootPath; " arc" |]
113+ let gitignorePath = join [| arcPath; " .gitignore" |]
114+ let notesReadmePath = join [| arcPath; NotesRootFolderName; NotesReadmeFileName |]
115+
116+ try
117+ do ! mkdirRecursiveAsync arcPath
118+
119+ let arc = ARC( " ScaffoldArc" )
120+
121+ match ! arc.TryWriteAsyncSwate( arcPath) with
122+ | Error errors -> failwith ( String.concat " \n " errors)
123+ | Ok _ -> ()
124+
125+ let! gitignoreContent = readFileAsync gitignorePath TextEncoding.Utf8
126+ let! notesReadmeContent = readFileAsync notesReadmePath TextEncoding.Utf8
127+ Vitest.expect( gitignoreContent) .toBe ( arctrlDefaultGitignoreContent ())
128+ Vitest.expect( notesReadmeContent) .toBe ( NotesReadmeContent)
129+ do ! TestHelpers.removeDirectoryAsync rootPath
130+ with error ->
131+ do ! TestHelpers.removeDirectoryAsync rootPath
132+ return raise error
133+ }
134+ )
135+
100136 Vitest.test (
101137 " TryWriteAsyncSwate preserves payload and does not create unmanaged file-tree entries" ,
102138 fun () -> promise {
0 commit comments