Skip to content

Commit 0d6c9ff

Browse files
committed
Apply formatting
1 parent 635df05 commit 0d6c9ff

File tree

4 files changed

+63
-48
lines changed

4 files changed

+63
-48
lines changed

src/Library.fs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ type ChangelogExtensions =
3232
(string section.Type,
3333
section.ItemCollection
3434
|> Seq.map _.MarkdownText
35-
|> String.concat Environment.NewLine))
35+
|> String.concat Environment.NewLine)
36+
)
3637

3738
[<Extension>]
3839
static member ToTaskItem(unreleased: ChangelogSectionUnreleased) =
@@ -51,9 +52,12 @@ type ChangelogExtensions =
5152
| false, _ -> None
5253
| true, version ->
5354
Some
54-
{| version = version
55-
date = section.ToDateTime()
56-
collection = section.SubSectionCollection |})
55+
{|
56+
version = version
57+
date = section.ToDateTime()
58+
collection = section.SubSectionCollection
59+
|}
60+
)
5761

5862
[<Extension>]
5963
static member ToMarkdown(subsections: ChangelogSubSectionCollection) =
@@ -62,12 +66,13 @@ type ChangelogExtensions =
6266
subsections
6367
|> Seq.fold
6468
(fun (builder: StringBuilder) subsection ->
65-
let state = builder.AppendLine $"### {subsection.Type}"
66-
|> (fun x -> x.AppendLine "")
69+
let state =
70+
builder.AppendLine $"### {subsection.Type}" |> (fun x -> x.AppendLine "")
6771

6872
subsection.ItemCollection
6973
|> Seq.fold (fun (builder: StringBuilder) line -> builder.AppendLine $"- {line.MarkdownText}") state
70-
|> (fun x -> x.AppendLine ""))
74+
|> (fun x -> x.AppendLine "")
75+
)
7176
builder
7277
|> _.ToString()
7378
|> _.Trim()
@@ -146,7 +151,8 @@ type ParseChangeLogs() =
146151
for (key, value) in x.collection.ToTaskItemMetadata() do
147152
taskItem.SetMetadata(key, value)
148153

149-
taskItem :> ITaskItem)
154+
taskItem :> ITaskItem
155+
)
150156

151157
this.CurrentReleaseChangelog <- mapped[0]
152158
this.AllReleasedChangelogs <- mapped

src/Log.fs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,13 @@ let changelogFileNotFound (filePath: string) =
1919
ErrorCode = "IKC0001"
2020
HelpKeyword = "Missing Changelog file"
2121
Message = "The Changelog file {0} was not found."
22-
MessageArgs =
23-
[|
24-
box filePath
25-
|]
22+
MessageArgs = [| box filePath |]
2623
}
2724

2825
let invalidChangelog (filePath: string) (error: string) =
2926
{
3027
ErrorCode = "IKC0002"
3128
HelpKeyword = "Invalid Changelog file"
3229
Message = "The Changelog file {0} is invalid. The error was: {1}"
33-
MessageArgs =
34-
[|
35-
box filePath
36-
box error
37-
|]
30+
MessageArgs = [| box filePath; box error |]
3831
}

tests/IntegrationTests.fs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ open Faqt
99
open SimpleExec
1010
open Workspace
1111

12-
1312
module Utils =
1413
let packAndGetPackageProperties projectName =
1514
let packageCache = VirtualWorkspace.``test-package-cache``.``.``
15+
1616
if Directory.Exists packageCache then
1717
Directory.Delete(packageCache, true)
18+
1819
Directory.CreateDirectory packageCache |> ignore
20+
1921
Command.Run(
2022
"dotnet",
2123
CmdLine.empty
@@ -24,6 +26,7 @@ module Utils =
2426
|> CmdLine.toString,
2527
workingDirectory = Workspace.fixtures.``.``
2628
)
29+
2730
Command.ReadAsync(
2831
"dotnet",
2932
CmdLine.empty
@@ -39,8 +42,8 @@ module Utils =
3942

4043
type StringHelper =
4144
[<Extension>]
42-
static member ReplaceEscapedNewLines (s: string) =
43-
s.ReplaceLineEndings().Replace("\\r\\n","\\n")
45+
static member ReplaceEscapedNewLines(s: string) =
46+
s.ReplaceLineEndings().Replace("\\r\\n", "\\n")
4447

4548
[<TestClass>]
4649
type IntegrationTests() =
@@ -52,7 +55,6 @@ type IntegrationTests() =
5255

5356
this.testPackageVersion <- $"0.0.1-test-{suffix}"
5457

55-
5658
// Create a package to be used in the tests
5759
// I didn't find a way to test the MSBuild tasks execution using MSBuild only
5860
// So each fsproj, will use a package reference to the package created here
@@ -78,7 +80,6 @@ type IntegrationTests() =
7880
workingDirectory = Workspace.fixtures.``.``
7981
)
8082

81-
8283
[<TestMethod>]
8384
member this.``works for absolute path with keep a changelog``() : Task =
8485
task {

tests/UnitTests.fs

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,33 @@ open Faqt.Operators
88
open Microsoft.VisualStudio.TestTools.UnitTesting
99
open Workspace
1010

11-
type TestContext =
12-
{
13-
BuildEngine: Mock<IBuildEngine>
14-
Errors: ResizeArray<BuildErrorEventArgs>
15-
}
11+
type TestContext = {
12+
BuildEngine: Mock<IBuildEngine>
13+
Errors: ResizeArray<BuildErrorEventArgs>
14+
} with
1615

1716
member this.PrintErrors() =
1817
this.Errors |> Seq.iter (fun error -> printfn "Error: %s" error.Message)
18+
1919
[<TestClass>]
2020
type UnitTests() =
2121

2222
member val context = Unchecked.defaultof<TestContext> with get, set
23+
2324
[<TestInitialize>]
2425
member this.Initialize() =
25-
this.context <-
26-
{
27-
BuildEngine = Mock<IBuildEngine>()
28-
Errors = ResizeArray<BuildErrorEventArgs>()
29-
}
26+
this.context <- {
27+
BuildEngine = Mock<IBuildEngine>()
28+
Errors = ResizeArray<BuildErrorEventArgs>()
29+
}
3030

3131
this.context.BuildEngine
3232
.Setup(fun engine -> engine.LogErrorEvent(It.IsAny<BuildErrorEventArgs>()))
3333
.Callback(fun (args: BuildErrorEventArgs) -> this.context.Errors.Add(args))
3434
|> ignore
3535

3636
[<TestMethod>]
37-
member this.``task fails when changelog file does not exist`` () =
37+
member this.``task fails when changelog file does not exist``() =
3838

3939
let myTask = ParseChangeLogs(ChangelogFile = "ThisFileDoesNotExist.md")
4040
myTask.BuildEngine <- this.context.BuildEngine.Object
@@ -46,7 +46,7 @@ type UnitTests() =
4646
%this.context.Errors.[0].Code.Should().Be("IKC0001")
4747

4848
[<TestMethod>]
49-
member this.``task succeeds when changelog file exists (relative path)`` () =
49+
member this.``task succeeds when changelog file exists (relative path)``() =
5050
// When running tests, the working directory is where the dll is located
5151
let myTask = ParseChangeLogs(ChangelogFile = "../../../changelogs/CHANGELOG.md")
5252

@@ -60,7 +60,7 @@ type UnitTests() =
6060
%this.context.Errors.Count.Should().Be(0)
6161

6262
[<TestMethod>]
63-
member this.``task succeeds when changelog file exists (absolute path)`` () =
63+
member this.``task succeeds when changelog file exists (absolute path)``() =
6464
let myTask = ParseChangeLogs(ChangelogFile = Workspace.changelogs.``CHANGELOG.md``)
6565
myTask.BuildEngine <- this.context.BuildEngine.Object
6666

@@ -70,7 +70,7 @@ type UnitTests() =
7070
%this.context.Errors.Count.Should().Be(0)
7171

7272
[<TestMethod>]
73-
member this.``task fails when changelog file is invalid`` () =
73+
member this.``task fails when changelog file is invalid``() =
7474
let myTask =
7575
ParseChangeLogs(ChangelogFile = Workspace.changelogs.``CHANGELOG_invalid.md``)
7676

@@ -82,9 +82,8 @@ type UnitTests() =
8282
%this.context.Errors.Count.Should().Be(1)
8383
%this.context.Errors.[0].Code.Should().Be("IKC0002")
8484

85-
8685
[<TestMethod>]
87-
member this.``task correctly parses details from changelog file`` () =
86+
member this.``task correctly parses details from changelog file``() =
8887
let myTask =
8988
ParseChangeLogs(ChangelogFile = Workspace.changelogs.``CHANGELOG_detailed.md``)
9089

@@ -93,26 +92,42 @@ type UnitTests() =
9392
let success = myTask.Execute()
9493
%success.Should().BeTrue "Should have successfully parsed the changelog data"
9594
%myTask.AllReleasedChangelogs.Length.Should().Be(9, "Should have 9 versions")
96-
%myTask.CurrentReleaseChangelog.ItemSpec.Should().Be("0.1.8", "Should have the most recent version")
97-
%myTask.CurrentReleaseChangelog.GetMetadata("Date").Should().Be("2022-03-31", "Should have the most recent version's date")
98-
%(myTask.CurrentReleaseChangelog.MetadataNames |> Seq.cast |> _.Should().Contain("Changed", "Should have changed metadata"))
99-
%(myTask.CurrentReleaseChangelog.MetadataNames |> Seq.cast |> _.Should().Contain("Date", "Should have date metadata"))
95+
96+
%myTask.CurrentReleaseChangelog.ItemSpec
97+
.Should()
98+
.Be("0.1.8", "Should have the most recent version")
99+
100+
%myTask.CurrentReleaseChangelog
101+
.GetMetadata("Date")
102+
.Should()
103+
.Be("2022-03-31", "Should have the most recent version's date")
104+
105+
%(myTask.CurrentReleaseChangelog.MetadataNames
106+
|> Seq.cast
107+
|> _.Should().Contain("Changed", "Should have changed metadata"))
108+
109+
%(myTask.CurrentReleaseChangelog.MetadataNames
110+
|> Seq.cast
111+
|> _.Should().Contain("Date", "Should have date metadata"))
100112

101113
[<TestMethod>]
102-
member this.``task produces expected markdown`` () =
103-
let myTask =
104-
ParseChangeLogs(ChangelogFile = Workspace.changelogs.``CHANGELOG.md``)
114+
member this.``task produces expected markdown``() =
115+
let myTask = ParseChangeLogs(ChangelogFile = Workspace.changelogs.``CHANGELOG.md``)
105116

106117
myTask.BuildEngine <- this.context.BuildEngine.Object
107118

108119
let success = myTask.Execute()
109120
%success.Should().BeTrue "Should have successfully parsed the changelog data"
110-
%myTask.LatestReleaseNotes.Should().Be("""### Added
121+
122+
%myTask.LatestReleaseNotes
123+
.Should()
124+
.Be(
125+
"""### Added
111126
112127
- Created the package
113128
114129
### Changed
115130
116131
- Changed something in the package
117-
- Updated the target framework""")
118-
132+
- Updated the target framework"""
133+
)

0 commit comments

Comments
 (0)