Skip to content

Commit

Permalink
More project structure type asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimmy Byrd committed Jan 23, 2020
1 parent 420b27e commit ec7b48c
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 15 deletions.
52 changes: 41 additions & 11 deletions tests/MiniScaffold.Tests/Asserts.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,51 @@ module Assert =
| None -> failtest msg

let private tryFindFile file (d : DirectoryInfo) =
d.GetFiles()
|> Seq.tryFind(fun x -> x.Name = file)
|> failIfNoneWithMsg (sprintf "Could not find %s in %s" file d.FullName)
let filepath = Path.Combine(d.FullName, file)
if filepath |> File.Exists |> not then
failtestf "Could not find %s" filepath

let ``project can build target`` target (d : DirectoryInfo) =
Builds.executeBuild d.FullName target

let ``.editorconfig exists`` (d : DirectoryInfo) =
tryFindFile ".editorconfig" d
let ``.config/dotnet-tools.json exists`` =
tryFindFile ".config/dotnet-tools.json"

let ``.gitattributes exists`` (d : DirectoryInfo) =
tryFindFile ".gitattributes" d
let ``.github ISSUE_TEMPLATE bug_report exists`` =
tryFindFile ".github/ISSUE_TEMPLATE/bug_report.md"

let ``paket.lock exists`` (d : DirectoryInfo) =
tryFindFile "paket.lock" d
let ``.github ISSUE_TEMPLATE feature_request exists`` =
tryFindFile ".github/ISSUE_TEMPLATE/feature_request.md"

let ``paket.dependencies exists`` (d : DirectoryInfo) =
tryFindFile "paket.dependencies" d
let ``.github workflows build exists`` =
tryFindFile ".github/workflows/build.yml"

let ``.github ISSUE_TEMPLATE exists`` =
tryFindFile ".github/ISSUE_TEMPLATE.md"

let ``.github PULL_REQUEST_TEMPLATE exists`` =
tryFindFile ".github/PULL_REQUEST_TEMPLATE.md"

let ``.editorconfig exists`` =
tryFindFile ".editorconfig"

let ``.gitattributes exists`` =
tryFindFile ".gitattributes"

let ``.gitignore exists`` =
tryFindFile ".gitignore"

let ``LICENSE exists`` =
tryFindFile "LICENSE.md"

let ``paket.lock exists`` =
tryFindFile "paket.lock"

let ``paket.dependencies exists`` =
tryFindFile "paket.dependencies"

let ``README exists`` =
tryFindFile "README.md"

let ``RELEASE_NOTES exists`` =
tryFindFile "RELEASE_NOTES.md"
18 changes: 14 additions & 4 deletions tests/MiniScaffold.Tests/Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,21 @@ module Tests =



let commonAsserts = [
let projectStructureAsserts = [
Assert.``.config/dotnet-tools.json exists``
Assert.``.github ISSUE_TEMPLATE bug_report exists``
Assert.``.github ISSUE_TEMPLATE feature_request exists``
Assert.``.github workflows build exists``
Assert.``.github ISSUE_TEMPLATE exists``
Assert.``.github PULL_REQUEST_TEMPLATE exists``
Assert.``.editorconfig exists``
Assert.``.gitattributes exists``
Assert.``.gitignore exists``
Assert.``LICENSE exists``
Assert.``paket.dependencies exists``
Assert.``paket.lock exists``
Assert.``README exists``
Assert.``RELEASE_NOTES exists``
]

[<Tests>]
Expand All @@ -51,17 +61,17 @@ module Tests =
do setup ()
yield! [
"-n MyCoolLib --githubUsername CoolPersonNo2", [
yield! commonAsserts
yield! projectStructureAsserts
Assert.``project can build target`` "DotnetPack"
Assert.``project can build target`` "BuildDocs"
]
// test for dashes in name https://github.com/dotnet/templating/issues/1168#issuecomment-364592031
"-n fsharp-data-sample --githubUsername CoolPersonNo2", [
yield! commonAsserts
yield! projectStructureAsserts
Assert.``project can build target`` "DotnetPack"
]
"-n MyCoolApp --githubUsername CoolPersonNo2 --outputType Console", [
yield! commonAsserts
yield! projectStructureAsserts
Assert.``project can build target`` "CreatePackages"
]

Expand Down

0 comments on commit ec7b48c

Please sign in to comment.