@@ -3,8 +3,8 @@ module Fable.Package.SDK.Tests
3
3
// open Microsoft.VisualStudio.TestTools.UnitTesting
4
4
open SimpleExec
5
5
open NUnit.Framework
6
- open Thoth. Json . Core
7
- open Thoth. Json . Newtonsoft
6
+ open System. IO
7
+ open System. IO . Compression
8
8
9
9
let private expectToFailWithMessage projectName ( message : string ) =
10
10
task {
@@ -221,62 +221,35 @@ let ``should support multiple fable targets`` () =
221
221
)
222
222
}
223
223
224
- type MSBuildItem =
225
- {
226
- FullPath: string
227
- Pack: bool
228
- }
229
-
230
- static member Decoder =
231
- Decode.object ( fun get ->
232
- {
233
- FullPath = get.Required.Field " FullPath" Decode.string
234
- Pack =
235
- get.Required.Field
236
- " Pack"
237
- ( Decode.string
238
- |> Decode.andThen (
239
- function
240
- | " true" -> Decode.succeed true
241
- | " false" -> Decode.succeed false
242
- | _ -> Decode.fail " Invalid boolean value"
243
- ))
244
- }
245
- )
246
-
247
224
[<Test>]
248
225
let ``should include the source file and the project file under 'fable' folder`` () =
249
226
task {
250
- let! stdout , _ =
251
- Command.ReadAsync(
252
- " dotnet" ,
253
- $" msbuild %s {Workspace.fixtures.valid.``library-with-files``.``MyLibrary.fsproj``} --getItem:None --getItem:Compile"
254
- )
227
+ // Make sure we work with a fresh nupkg file
228
+ let fileInfo =
229
+ VirtualWorkspace.fixtures.valid.`` library-with-files `` .bin.Release.`` MyLibrary.1.0.0.nupkg ``
230
+ |> FileInfo
255
231
256
- let projectFile =
257
- Decode.unsafeFromString
258
- ( Decode.at [ " Items" ; " None" ] ( Decode.list MSBuildItem.Decoder))
259
- stdout
260
- // We are only interested in the project file
261
- |> List.filter ( fun item -> item.FullPath.Contains( " MyLibrary.fsproj" ))
262
- |> List.head
232
+ fileInfo.Delete()
263
233
264
- let compileItem =
265
- Decode.unsafeFromString
266
- ( Decode.at [ " Items " ; " Compile " ] ( Decode.index 0 MSBuildItem.Decoder ))
267
- stdout
234
+ Command.Run (
235
+ " dotnet " ,
236
+ $ " pack %s {Workspace.fixtures.valid.``library-with-files``.``MyLibrary.fsproj``} "
237
+ )
268
238
269
- Assert.That( compileItem.Pack, Is.True)
239
+ let archive = ZipFile.OpenRead( VirtualWorkspace.fixtures.valid.`` library-with-files `` .bin.Release.`` MyLibrary.1.0.0.nupkg `` )
240
+
241
+ let entries =
242
+ archive.Entries
243
+ |> Seq.map ( fun entry -> entry.FullName)
244
+ |> Seq.toList
270
245
271
246
Assert.That(
272
- compileItem.FullPath ,
273
- Contains.Substring ( " tests/fixtures/valid/library-with-files /Entry.fs" )
247
+ entries ,
248
+ Contains.Item ( " fable /Entry.fs" )
274
249
)
275
250
276
- Assert.That( projectFile.Pack, Is.True)
277
-
278
251
Assert.That(
279
- projectFile.FullPath ,
280
- Contains.Substring ( " tests/fixtures/valid/library-with-files /MyLibrary.fsproj" )
252
+ entries ,
253
+ Contains.Item ( " fable /MyLibrary.fsproj" )
281
254
)
282
255
}
0 commit comments