Skip to content

Commit

Permalink
Fix tests in GS64
Browse files Browse the repository at this point in the history
  • Loading branch information
gcotelli committed Sep 20, 2023
1 parent d1438b2 commit 513bd87
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -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!<n>' 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' )
]
40 changes: 11 additions & 29 deletions source/Launchpad-Commands-Tests/LaunchpadRootCommandTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 [

Expand Down Expand Up @@ -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!<n>' 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 [

Expand Down Expand Up @@ -781,7 +763,7 @@ LaunchpadRootCommandTest >> testHandlingStartSubcommandHelp [
onExitDo: [ :exit | self assert: exit isSuccess ].

self
assert: output equals: self expectedStartHelpOutput;
assert: output isLineEndingInsensitiveEqualsTo: self expectedStartHelpOutput;
assertThereAreNoLogRecords
]

Expand All @@ -795,7 +777,7 @@ LaunchpadRootCommandTest >> testHandlingStartSubcommandShortHelp [
onExitDo: [ :exit | self assert: exit isSuccess ].

self
assert: output equals: self expectedStartHelpOutput;
assert: output isLineEndingInsensitiveEqualsTo: self expectedStartHelpOutput;
assertThereAreNoLogRecords
]

Expand Down Expand Up @@ -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] <command>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 [

Expand Down Expand Up @@ -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
Expand All @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ ConfigurationFromJsonSettingsFileProvider >> valueFor: aConfigurationParameter i
valueFor: aConfigurationParameter
ifFound: aPresentBlock
ifNone: aFailBlock ]
ifNotNil: aPresentBlock
ifNotNil: [ :value | aPresentBlock cull: value ]
]

0 comments on commit 513bd87

Please sign in to comment.