github.com/jghiloni/cli@v6.28.1-0.20170628223758-0ce05fe032a2+incompatible/integration/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"))
    17  			Eventually(session).Should(Say("SYNTAXE :"))
    18  			// Eventually(session).Should(Say("Envoyez par commande push")) // TODO: Uncomment when language files have been updated
    19  			Eventually(session).Should(Say("-i\\s+Nombre d'instances"))
    20  			Eventually(session).Should(Exit(0))
    21  		},
    22  
    23  		Entry("when the locale is set in the config", func() *Session {
    24  			session := helpers.CF("config", "--locale", "fr-FR")
    25  			Eventually(session).Should(Exit(0))
    26  
    27  			return helpers.CF("push", "--help")
    28  		}),
    29  
    30  		Entry("when the the config and LANG environment variable is set, it uses config", func() *Session {
    31  			session := helpers.CF("config", "--locale", "fr-FR")
    32  			Eventually(session).Should(Exit(0))
    33  
    34  			return helpers.CFWithEnv(map[string]string{"LANG": "es-ES"}, "push", "--help")
    35  		}),
    36  
    37  		Entry("when the the LANG environment variable is set", func() *Session {
    38  			return helpers.CFWithEnv(map[string]string{"LANG": "fr-FR"}, "push", "--help")
    39  		}),
    40  
    41  		Entry("when the the LC_ALL environment variable is set", func() *Session {
    42  			return helpers.CFWithEnv(map[string]string{"LC_ALL": "fr-FR"}, "push", "--help")
    43  		}),
    44  
    45  		Entry("when the the LC_ALL and LANG environment variables are set, it uses LC_ALL", func() *Session {
    46  			return helpers.CFWithEnv(map[string]string{"LC_ALL": "fr-FR", "LANG": "es-ES"}, "push", "--help")
    47  		}),
    48  
    49  		Entry("when the the config, LC_ALL, and LANG is set, it uses config", func() *Session {
    50  			session := helpers.CF("config", "--locale", "fr-FR")
    51  			Eventually(session).Should(Exit(0))
    52  
    53  			return helpers.CFWithEnv(map[string]string{"LC_ALL": "ja-JP", "LANG": "es-ES"}, "push", "--help")
    54  		}),
    55  	)
    56  
    57  	DescribeTable("defaults to English",
    58  		func(setup func() *Session) {
    59  			session := setup()
    60  			Eventually(session).Should(Say("push - Push a new app or sync changes to an existing app"))
    61  			Eventually(session).Should(Exit(0))
    62  		},
    63  
    64  		Entry("when the the LANG and LC_ALL environment variable is not set", func() *Session {
    65  			return helpers.CF("push", "--help")
    66  		}),
    67  
    68  		Entry("when the the LANG environment variable is set to a non-supported langauge", func() *Session {
    69  			return helpers.CFWithEnv(map[string]string{"LANG": "jj-FF"}, "push", "--help")
    70  		}),
    71  
    72  		Entry("when the the LC_ALL environment variable is set to a non-supported langauge", func() *Session {
    73  			return helpers.CFWithEnv(map[string]string{"LC_ALL": "jj-FF"}, "push", "--help")
    74  		}),
    75  	)
    76  })