Skip to content

Commit

Permalink
Fix tests broken do to NeoJSON updates
Browse files Browse the repository at this point in the history
  • Loading branch information
gcotelli committed Nov 21, 2023
1 parent 946a43e commit 767df30
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
I'm the test case for the Application Configuration API
"
Class {
#name : #ApplicationConfigurationPluginAPITest,
#superclass : #OperationalPluginAPITest,
#category : #'Stargate-Application-Configuration-Tests'
#name : 'ApplicationConfigurationPluginAPITest',
#superclass : 'OperationalPluginAPITest',
#category : 'Stargate-Application-Configuration-Tests',
#package : 'Stargate-Application-Configuration-Tests'
}

{ #category : #private }
{ #category : 'private' }
ApplicationConfigurationPluginAPITest >> configurationParameters [

^ Array with: ( MandatoryConfigurationParameter named: 'Public URL' describedBy: 'Public URL' )
]

{ #category : #private }
{ #category : 'private' }
ApplicationConfigurationPluginAPITest >> configurationProvider [

^ [
Expand All @@ -23,7 +24,7 @@ ApplicationConfigurationPluginAPITest >> configurationProvider [
]
]

{ #category : #running }
{ #category : 'running' }
ApplicationConfigurationPluginAPITest >> operationsConfiguration [

^ super operationsConfiguration
Expand All @@ -36,13 +37,13 @@ ApplicationConfigurationPluginAPITest >> operationsConfiguration [
yourself
]

{ #category : #private }
{ #category : 'private' }
ApplicationConfigurationPluginAPITest >> requiredPermissions [

^ #('read:application-configuration')
]

{ #category : #tests }
{ #category : 'tests' }
ApplicationConfigurationPluginAPITest >> testDisablePlugin [

self assertIsEnabled: ApplicationConfigurationPlugin.
Expand All @@ -62,7 +63,7 @@ ApplicationConfigurationPluginAPITest >> testDisablePlugin [
withExceptionDo: [ :error | self assert: error response isNotFound ]
]

{ #category : #tests }
{ #category : 'tests' }
ApplicationConfigurationPluginAPITest >> testEnablePreviouslyDisabledPlugin [

self assertIsEnabled: ApplicationConfigurationPlugin.
Expand All @@ -76,7 +77,7 @@ ApplicationConfigurationPluginAPITest >> testEnablePreviouslyDisabledPlugin [
self testGetConfigurationWithPermissions
]

{ #category : #tests }
{ #category : 'tests' }
ApplicationConfigurationPluginAPITest >> testGetConfigurationWithPermissions [

| response |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,27 @@
I'm a test for API configuration options
"
Class {
#name : #ApplicationConfigurationPluginConfigurationAPITest,
#superclass : #OperationalPluginAPITest,
#category : #'Stargate-Application-Configuration-Tests'
#name : 'ApplicationConfigurationPluginConfigurationAPITest',
#superclass : 'OperationalPluginAPITest',
#category : 'Stargate-Application-Configuration-Tests',
#package : 'Stargate-Application-Configuration-Tests'
}

{ #category : #running }
{ #category : 'running' }
ApplicationConfigurationPluginConfigurationAPITest >> operationsConfiguration [

^ super operationsConfiguration
at: ApplicationConfigurationPlugin endpoint put: { #enabled -> false } asDictionary;
yourself
]

{ #category : #private }
{ #category : 'private' }
ApplicationConfigurationPluginConfigurationAPITest >> requiredPermissions [

^ #('read:application-configuration')
]

{ #category : #tests }
{ #category : 'tests' }
ApplicationConfigurationPluginConfigurationAPITest >> testPluginIsDisabled [

self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
An ApplicationConfigurationPluginTest is a test class for testing the behavior of ApplicationConfigurationPlugin
"
Class {
#name : #ApplicationConfigurationPluginTest,
#superclass : #TestCase,
#category : #'Stargate-Application-Configuration-Tests'
#name : 'ApplicationConfigurationPluginTest',
#superclass : 'TestCase',
#category : 'Stargate-Application-Configuration-Tests',
#package : 'Stargate-Application-Configuration-Tests'
}

{ #category : #accessing }
{ #category : 'accessing' }
ApplicationConfigurationPluginTest >> configuration [

^ Dictionary new
Expand All @@ -20,7 +21,7 @@ ApplicationConfigurationPluginTest >> configuration [
yourself
]

{ #category : #accessing }
{ #category : 'accessing' }
ApplicationConfigurationPluginTest >> configurationParameters [

^ Array
Expand All @@ -35,7 +36,7 @@ ApplicationConfigurationPluginTest >> configurationParameters [
convertingWith: [ :value | value = 'true' ] )
]

{ #category : #accessing }
{ #category : 'accessing' }
ApplicationConfigurationPluginTest >> configurationProvider [

^ [
Expand All @@ -46,7 +47,7 @@ ApplicationConfigurationPluginTest >> configurationProvider [
]
]

{ #category : #tests }
{ #category : 'tests' }
ApplicationConfigurationPluginTest >> testConfigurationAccessing [

| plugin parameter |
Expand Down Expand Up @@ -74,19 +75,19 @@ ApplicationConfigurationPluginTest >> testConfigurationAccessing [
assert: ( plugin currentValueFor: parameter )
]

{ #category : #tests }
{ #category : 'tests' }
ApplicationConfigurationPluginTest >> testEnabledByDefault [

self deny: ApplicationConfigurationPlugin enabledByDefault
]

{ #category : #tests }
{ #category : 'tests' }
ApplicationConfigurationPluginTest >> testEndpoint [

self assert: ApplicationConfigurationPlugin endpoint equals: 'application-configuration'
]

{ #category : #tests }
{ #category : 'tests' }
ApplicationConfigurationPluginTest >> testPluginName [

self assert: ApplicationConfigurationPlugin pluginName equals: 'Application Configuration'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
An ApplicationConfigurationRESTfulControllerTest is a test class for testing the behavior of ApplicationConfigurationRESTfulController
"
Class {
#name : #ApplicationConfigurationRESTfulControllerTest,
#superclass : #OperationalPluginRESTfulControllerTest,
#category : #'Stargate-Application-Configuration-Tests'
#name : 'ApplicationConfigurationRESTfulControllerTest',
#superclass : 'OperationalPluginRESTfulControllerTest',
#category : 'Stargate-Application-Configuration-Tests',
#package : 'Stargate-Application-Configuration-Tests'
}

{ #category : #'private - support' }
{ #category : 'private - support' }
ApplicationConfigurationRESTfulControllerTest >> configurationParameters [

^ Array
Expand All @@ -25,7 +26,7 @@ ApplicationConfigurationRESTfulControllerTest >> configurationParameters [
asSensitive
]

{ #category : #'private - support' }
{ #category : 'private - support' }
ApplicationConfigurationRESTfulControllerTest >> configurationProvider [

^ [
Expand All @@ -36,7 +37,7 @@ ApplicationConfigurationRESTfulControllerTest >> configurationProvider [
]
]

{ #category : #'private - support' }
{ #category : 'private - support' }
ApplicationConfigurationRESTfulControllerTest >> operationsConfiguration [

^ super operationsConfiguration
Expand All @@ -49,15 +50,15 @@ ApplicationConfigurationRESTfulControllerTest >> operationsConfiguration [
yourself
]

{ #category : #'private - support' }
{ #category : 'private - support' }
ApplicationConfigurationRESTfulControllerTest >> setUpResourceController [

resourceController := ApplicationConfigurationRESTfulController
over: ( ApplicationConfigurationPlugin configuredBy: self operationsConfiguration )
configuredBy: self operationsConfiguration
]

{ #category : #'private - support' }
{ #category : 'private - support' }
ApplicationConfigurationRESTfulControllerTest >> testGetConfigurationInJson [

| response |
Expand Down Expand Up @@ -112,13 +113,13 @@ ApplicationConfigurationRESTfulControllerTest >> testGetConfigurationInJson [
assert: config attributeName equals: 'secret';
assert: config commandLineArgumentName equals: 'vault.secret';
assert: config environmentVariableName equals: 'VAULT__SECRET';
assert: config sections equals: #( 'Vault' );
assert: config sections hasTheSameElementsInTheSameOrderThat: #( 'Vault' );
assert: ( config at: #'current-value' ) equals: '**********'
]
]
]

{ #category : #'private - support' }
{ #category : 'private - support' }
ApplicationConfigurationRESTfulControllerTest >> testGetConfigurationInPlainText [

| response |
Expand All @@ -137,7 +138,7 @@ ApplicationConfigurationRESTfulControllerTest >> testGetConfigurationInPlainText
with: String lf )
]

{ #category : #'private - support' }
{ #category : 'private - support' }
ApplicationConfigurationRESTfulControllerTest >> withConfigurationNamed: aName in: configurations do: aBlock [

configurations detect: [ :config | config name = aName ] ifFound: aBlock ifNone: [ self fail ]
Expand Down
2 changes: 1 addition & 1 deletion source/Stargate-Application-Configuration-Tests/package.st
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Package { #name : #'Stargate-Application-Configuration-Tests' }
Package { #name : 'Stargate-Application-Configuration-Tests' }
Original file line number Diff line number Diff line change
Expand Up @@ -593,5 +593,5 @@ PetOrdersRESTfulControllerTest >> testUpdateCommentAcceptingADifferentMediaType
assert: response isSuccess;
assert: response contentType equals: ZnMimeType applicationJson;
withJsonFromContentsIn: response
do: [ :json | self assert: json equals: #( 'Hola!' 'Mr. DJ' ) ] ]
do: [ :json | self assert: json hasTheSameElementsInTheSameOrderThat: #( 'Hola!' 'Mr. DJ' ) ] ]
]
Original file line number Diff line number Diff line change
Expand Up @@ -401,11 +401,12 @@ SouthAmericanCurrenciesRESTfulControllerTest >> testGetCurrencies [
assert: response varyHeaderNames includes: 'Accept'.
self assertCachingDirectivesFor: response with: #( 'immutable' 'Max-Age=86400' ).

self withJsonFromContentsIn: response do: [ :currencies |
self withJsonFromContentsIn: response do: [ :currencies |
self
assert: currencies size equals: 11;
assert: ( currencies collect: #isoCode )
equals: #( 'ARS' 'BOB' 'BRL' 'CLP' 'COP' 'GYD' 'PYG' 'PEN' 'SRD' 'UYU' 'VES' )
hasTheSameElementsInTheSameOrderThat:
#( 'ARS' 'BOB' 'BRL' 'CLP' 'COP' 'GYD' 'PYG' 'PEN' 'SRD' 'UYU' 'VES' )
]
]

Expand All @@ -414,7 +415,7 @@ SouthAmericanCurrenciesRESTfulControllerTest >> testGetCurrenciesInSpanish [

| response request |

request := self requestToGET: self resourceUrl applying: [ :requestConfig |
request := self requestToGET: self resourceUrl applying: [ :requestConfig |
requestConfig
setAccept: resourceController currencyVersion1dot0dot0MediaType;
setAcceptLanguage: self spanish
Expand All @@ -433,11 +434,12 @@ SouthAmericanCurrenciesRESTfulControllerTest >> testGetCurrenciesInSpanish [
assert: response varyHeaderNames includes: 'Accept'.
self assertCachingDirectivesFor: response with: #( 'immutable' 'Max-Age=86400' ).

self withJsonFromContentsIn: response do: [ :currencies |
self withJsonFromContentsIn: response do: [ :currencies |
self
assert: currencies size equals: 11;
assert: ( currencies collect: #isoCode )
equals: #( 'ARS' 'BOB' 'BRL' 'CLP' 'COP' 'GYD' 'PYG' 'PEN' 'SRD' 'UYU' 'VES' );
hasTheSameElementsInTheSameOrderThat:
#( 'ARS' 'BOB' 'BRL' 'CLP' 'COP' 'GYD' 'PYG' 'PEN' 'SRD' 'UYU' 'VES' );
assert: ( currencies anySatisfy: [ :currency | currency name = 'Real brasileño' ] )
]
]
Expand Down

0 comments on commit 767df30

Please sign in to comment.