Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(tests): fix conflict of variable scope by renaming local variables during upgrade of groovy 3.x #1341

Merged
merged 1 commit into from
Sep 21, 2023

Commits on Sep 21, 2023

  1. refactor(tests): fix conflict of variable scope by renaming local var…

    …iables during upgrade of groovy 3.x
    
    While upgrading groovy 3.0.10 and spockframework 2.0-groovy-3.0, encountered the following errors in groovy test compilation of echo-core and echo-notifications modules:
    
    ```
    startup failed:
    /echo/echo-core/src/test/groovy/com/netflix/spinnaker/echo/notification/AbstractEventNotificationAgentSpec.groovy: 42: The current scope already contains a variable of the name event
     @ line 42, column 43.
       Mock.sendNotifications(*_) >> { notifica
                                     ^
    1 error
    > Task :echo-core:compileTestGroovy FAILED
    ```
    
    ```
    startup failed:
    /echo/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/GithubNotificationAgentSpec.groovy: 50: The current scope already contains a variable of the name status
     @ line 50, column 31.
           github.updateCheck(*_) >> { token, repo, sha, status ->
                                     ^
    1 error
    > Task :echo-notifications:compileTestGroovy FAILED
    
    startup failed:
    /echo/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/GithubNotificationAgentSpec.groovy: 99: The current scope already contains a variable of the name status
     @ line 99, column 31.
           github.updateCheck(*_) >> { token, repo, sha, status ->
                                     ^
    1 error
    > Task :echo-notifications:compileTestGroovy FAILED
    ```
    
    ```
    startup failed:
    /echo/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/GoogleChatNotificationAgentSpec.groovy: 63: The current scope already contains a variable of the name webhookURL
     @ line 63, column 35.
           googleChat.sendMessage(*_) >> { webhookURL, message ->
                                         ^
    /echo/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/GoogleChatNotificationAgentSpec.groovy: 63: The current scope already contains a variable of the name message
     @ line 63, column 35.
           googleChat.sendMessage(*_) >> { webhookURL, message ->
                                         ^
    2 errors
    > Task :echo-notifications:compileTestGroovy FAILED
    
    > Task :echo-notifications:compileTestGroovy FAILED
    startup failed:
    /echo/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/GoogleChatNotificationAgentSpec.groovy: 92: The current scope already contains a variable of the name webhookURL
     @ line 92, column 35.
           googleChat.sendMessage(*_) >> { webhookURL, message ->
                                         ^
    1 error
    ```
    
    ```
    startup failed:
    /echo/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/SlackNotificationAgentSpec.groovy: 36: The current scope already contains a variable of the name channel
     @ line 36, column 30.
           slack.sendMessage(*_) >> { message, channel, asUser ->
                                    ^
    1 error
    > Task :echo-notifications:compileTestGroovy FAILED
    
    > Task :echo-notifications:compileTestGroovy FAILED
    startup failed:
    /echo/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/SlackNotificationAgentSpec.groovy: 62: The current scope already contains a variable of the name message
     @ line 62, column 30.
           slack.sendMessage(*_) >> { message, channel, asUser ->
                                    ^
    /echo/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/SlackNotificationAgentSpec.groovy: 62: The current scope already contains a variable of the name channel
     @ line 62, column 30.
           slack.sendMessage(*_) >> { message, channel, asUser ->
                                    ^
    2 errors
    
    startup failed:
    /echo/echo-notifications/src/test/groovy/com/netflix/spinnaker/echo/notification/SlackNotificationAgentSpec.groovy: 91: The current scope already contains a variable of the name channel
     @ line 91, column 30.
           slack.sendMessage(*_) >> { message, channel, asUser ->
                                    ^
    1 error
    > Task :echo-notifications:compileTestGroovy FAILED
    ```
    
    To fix this issue renamed the local variables to avoid the scope confilct with global variables.
    j-sandy committed Sep 21, 2023
    Configuration menu
    Copy the full SHA
    e74e4e2 View commit details
    Browse the repository at this point in the history