diff --git a/source/Launchpad-Commands-Pharo-Tests/LaunchpadRootCommandTest.extension.st b/source/Launchpad-Commands-Pharo-Tests/LaunchpadRootCommandTest.extension.st new file mode 100644 index 0000000..239fe20 --- /dev/null +++ b/source/Launchpad-Commands-Pharo-Tests/LaunchpadRootCommandTest.extension.st @@ -0,0 +1,27 @@ +Extension { #name : #LaunchpadRootCommandTest } + +{ #category : #'*Launchpad-Commands-Pharo-Tests' } +LaunchpadRootCommandTest >> testHandlingStartGreeterApplicationEnablingTCPCommandServer [ + + | output | + + output := self handle: { + 'launchpad'. + 'start'. + '--debug-mode'. + '--enable-tcp-command-server=0'. + LaunchpadGreeterApplication commandName. + '--name=John' }. + + self assert: output equals: 'Hi John!' expandMacros. + + self assertLogRecordsMatch: #( + '[INFO] Receiving commands over TCP/0' + '[INFO] greeter [v1.0.0] - A greetings application' + '[INFO] Obtaining configuration...' + '[WARNING] "Title" parameter not provided. Using default.' + '[INFO] Name: John' + '[INFO] Title: ' + '[INFO] Obtaining configuration... [DONE]' + '[INFO] Exit application' ) +] diff --git a/source/Launchpad-Commands-Tests/LaunchpadRootCommandTest.class.st b/source/Launchpad-Commands-Tests/LaunchpadRootCommandTest.class.st index 77505f4..fbefcde 100644 --- a/source/Launchpad-Commands-Tests/LaunchpadRootCommandTest.class.st +++ b/source/Launchpad-Commands-Tests/LaunchpadRootCommandTest.class.st @@ -10,6 +10,14 @@ Class { #category : #'Launchpad-Commands-Tests' } +{ #category : #private } +LaunchpadRootCommandTest >> assert: string isLineEndingInsensitiveEqualsTo: anotherString [ + + self + assert: (string withLineEndings: String lf) + equals: (anotherString withLineEndings: String lf) +] + { #category : #private } LaunchpadRootCommandTest >> assertCommandCanHandleNextArgumentIn: context [ @@ -544,32 +552,6 @@ LaunchpadRootCommandTest >> testHandlingStartGreeterApplicationEnablingStructure '[INFO] Exit application' ) ] -{ #category : #'tests - handling start subcommand' } -LaunchpadRootCommandTest >> testHandlingStartGreeterApplicationEnablingTCPCommandServer [ - - | output | - - output := self handle: { - 'launchpad'. - 'start'. - '--debug-mode'. - '--enable-tcp-command-server=0'. - LaunchpadGreeterApplication commandName. - '--name=John' }. - - self assert: output equals: 'Hi John!' expandMacros. - - self assertLogRecordsMatch: #( - '[INFO] Receiving commands over TCP/0' - '[INFO] greeter [v1.0.0] - A greetings application' - '[INFO] Obtaining configuration...' - '[WARNING] "Title" parameter not provided. Using default.' - '[INFO] Name: John' - '[INFO] Title: ' - '[INFO] Obtaining configuration... [DONE]' - '[INFO] Exit application' ) -] - { #category : #'tests - handling start subcommand' } LaunchpadRootCommandTest >> testHandlingStartGreeterApplicationInDebugMode [ @@ -781,7 +763,7 @@ LaunchpadRootCommandTest >> testHandlingStartSubcommandHelp [ onExitDo: [ :exit | self assert: exit isSuccess ]. self - assert: output equals: self expectedStartHelpOutput; + assert: output isLineEndingInsensitiveEqualsTo: self expectedStartHelpOutput; assertThereAreNoLogRecords ] @@ -795,7 +777,7 @@ LaunchpadRootCommandTest >> testHandlingStartSubcommandShortHelp [ onExitDo: [ :exit | self assert: exit isSuccess ]. self - assert: output equals: self expectedStartHelpOutput; + assert: output isLineEndingInsensitiveEqualsTo: self expectedStartHelpOutput; assertThereAreNoLogRecords ] @@ -847,7 +829,7 @@ LaunchpadRootCommandTest >> testPrintHelpOn [ help := String streamContents: [ :stream | command printHelpOn: stream ]. - self assert: help equals: 'NAME + self assert: help isLineEndingInsensitiveEqualsTo: 'NAME launchpad - A minimal application launcher SYNOPSYS launchpad [--version] [--help|-h] diff --git a/source/Launchpad-Configuration-Tests/ApplicationConfigurationTest.class.st b/source/Launchpad-Configuration-Tests/ApplicationConfigurationTest.class.st index 8d609d2..69edb0a 100644 --- a/source/Launchpad-Configuration-Tests/ApplicationConfigurationTest.class.st +++ b/source/Launchpad-Configuration-Tests/ApplicationConfigurationTest.class.st @@ -7,6 +7,14 @@ Class { #category : #'Launchpad-Configuration-Tests' } +{ #category : #private } +ApplicationConfigurationTest >> assert: string isLineEndingInsensitiveEqualsTo: anotherString [ + + self + assert: (string withLineEndings: String lf) + equals: (anotherString withLineEndings: String lf) +] + { #category : #private } ApplicationConfigurationTest >> commandLineProviderOver: arguments [ @@ -101,7 +109,7 @@ ApplicationConfigurationTest >> testAsEnvironment [ configuration := self newApplicationConfiguration. env := String streamContents: [ :stream | configuration asEnvironmentOn: stream ]. - self assert: env equals: '# Port + self assert: env isLineEndingInsensitiveEqualsTo: '# Port COMMUNICATIONS__HTTP__PORT=8086 # Scheme. Defaults to https COMMUNICATIONS__HTTP__SCHEME=https @@ -119,7 +127,7 @@ ApplicationConfigurationTest >> testAsIniFile [ configuration := self newApplicationConfiguration. ini := String streamContents: [ :stream | configuration asIniFileOn: stream ]. - self assert: ini equals: '; Public URL + self assert: ini isLineEndingInsensitiveEqualsTo: '; Public URL publicURL = https://api.example.com/ [Communications.HTTP] diff --git a/source/Launchpad-Configuration-Tests/MandatoryConfigurationParameterTest.class.st b/source/Launchpad-Configuration-Tests/MandatoryConfigurationParameterTest.class.st index 46501d5..649f8d1 100644 --- a/source/Launchpad-Configuration-Tests/MandatoryConfigurationParameterTest.class.st +++ b/source/Launchpad-Configuration-Tests/MandatoryConfigurationParameterTest.class.st @@ -107,13 +107,11 @@ MandatoryConfigurationParameterTest >> testNumberTransformation [ self should: [ self valueWhenSetting: parameter to: 'a story about an API' ] - raise: Error - withMessageText: 'Reading a number failed: a digit between 0 and 9 expected'. + raise: Error. self should: [ self valueWhenSetting: parameter to: '' ] raise: Error - withMessageText: 'Reading a number failed: a digit between 0 and 9 expected' ] { #category : #tests } diff --git a/source/Launchpad-Configuration-Tests/OptionalConfigurationParameterTest.class.st b/source/Launchpad-Configuration-Tests/OptionalConfigurationParameterTest.class.st index 3a10448..83278b8 100644 --- a/source/Launchpad-Configuration-Tests/OptionalConfigurationParameterTest.class.st +++ b/source/Launchpad-Configuration-Tests/OptionalConfigurationParameterTest.class.st @@ -112,13 +112,11 @@ OptionalConfigurationParameterTest >> testNumberTransformation [ self should: [ self valueWhenSetting: parameter to: 'a story about an API' ] - raise: Error - withMessageText: 'Reading a number failed: a digit between 0 and 9 expected'. + raise: Error. self should: [ self valueWhenSetting: parameter to: '' ] raise: Error - withMessageText: 'Reading a number failed: a digit between 0 and 9 expected' ] { #category : #tests } diff --git a/source/Launchpad-Configuration/ConfigurationFromJsonSettingsFileProvider.class.st b/source/Launchpad-Configuration/ConfigurationFromJsonSettingsFileProvider.class.st index 4a301c8..45c0302 100644 --- a/source/Launchpad-Configuration/ConfigurationFromJsonSettingsFileProvider.class.st +++ b/source/Launchpad-Configuration/ConfigurationFromJsonSettingsFileProvider.class.st @@ -59,5 +59,5 @@ ConfigurationFromJsonSettingsFileProvider >> valueFor: aConfigurationParameter i valueFor: aConfigurationParameter ifFound: aPresentBlock ifNone: aFailBlock ] - ifNotNil: aPresentBlock + ifNotNil: [ :value | aPresentBlock cull: value ] ]