github.com/cloudfoundry/cli@v7.1.0+incompatible/integration/shared/isolated/internationalization_test.go (about)

     1  package isolated
     2  
     3  import (
     4  	helpers "code.cloudfoundry.org/cli/integration/helpers"
     5  	. "github.com/onsi/ginkgo"
     6  	. "github.com/onsi/ginkgo/extensions/table"
     7  	. "github.com/onsi/gomega"
     8  	. "github.com/onsi/gomega/gbytes"
     9  	. "github.com/onsi/gomega/gexec"
    10  )
    11  
    12  var _ = Describe("internationalization", func() {
    13  	DescribeTable("outputs help in different languages",
    14  		func(setup func() *Session) {
    15  			session := setup()
    16  			Eventually(session).Should(Say("push - Envoyer par commande push"))
    17  			Eventually(session).Should(Say("SYNTAXE :"))
    18  			Eventually(session).Should(Say(`-p\s+Chemin d'accès au répertoire de l'application ou à un fichier zip du contenu du répertoire de l'application`))
    19  			Eventually(session).Should(Exit(0))
    20  		},
    21  
    22  		Entry("when the locale is set in the config", func() *Session {
    23  			session := helpers.CF("config", "--locale", "fr-FR")
    24  			Eventually(session).Should(Exit(0))
    25  
    26  			return helpers.CF("push", "--help")
    27  		}),
    28  
    29  		Entry("when the the config and LANG environment variable is set, it uses config", func() *Session {
    30  			session := helpers.CF("config", "--locale", "fr-FR")
    31  			Eventually(session).Should(Exit(0))
    32  
    33  			return helpers.CFWithEnv(map[string]string{"LANG": "es-ES"}, "push", "--help")
    34  		}),
    35  
    36  		Entry("when the the LANG environment variable is set", func() *Session {
    37  			return helpers.CFWithEnv(map[string]string{"LANG": "fr-FR"}, "push", "--help")
    38  		}),
    39  
    40  		Entry("when the the LC_ALL environment variable is set", func() *Session {
    41  			return helpers.CFWithEnv(map[string]string{"LC_ALL": "fr-FR"}, "push", "--help")
    42  		}),
    43  
    44  		Entry("when the the LC_ALL and LANG environment variables are set, it uses LC_ALL", func() *Session {
    45  			return helpers.CFWithEnv(map[string]string{"LC_ALL": "fr-FR", "LANG": "es-ES"}, "push", "--help")
    46  		}),
    47  
    48  		Entry("when the the config, LC_ALL, and LANG is set, it uses config", func() *Session {
    49  			session := helpers.CF("config", "--locale", "fr-FR")
    50  			Eventually(session).Should(Exit(0))
    51  
    52  			return helpers.CFWithEnv(map[string]string{"LC_ALL": "ja-JP", "LANG": "es-ES"}, "push", "--help")
    53  		}),
    54  	)
    55  
    56  	DescribeTable("defaults to English",
    57  		func(setup func() *Session) {
    58  			session := setup()
    59  			Eventually(session).Should(Say("push - Push a new app or sync changes to an existing app"))
    60  			Eventually(session).Should(Exit(0))
    61  		},
    62  
    63  		Entry("when the the LANG and LC_ALL environment variable is not set", func() *Session {
    64  			return helpers.CF("push", "--help")
    65  		}),
    66  
    67  		Entry("when the the LANG environment variable is set to a non-supported langauge", func() *Session {
    68  			return helpers.CFWithEnv(map[string]string{"LANG": "jj-FF"}, "push", "--help")
    69  		}),
    70  
    71  		Entry("when the the LC_ALL environment variable is set to a non-supported langauge", func() *Session {
    72  			return helpers.CFWithEnv(map[string]string{"LC_ALL": "jj-FF"}, "push", "--help")
    73  		}),
    74  	)
    75  })