github.com/everlongproject/i18n4go@v0.2.7-0.20201028180611-670cbaceaa6b/integration/show_missing_strings/d_option_test.go (about)

     1  package show_missing_strings_test
     2  
     3  import (
     4  	"os"
     5  	"path/filepath"
     6  
     7  	. "github.com/Liam-Williams/i18n4go/integration/test_helpers"
     8  	. "github.com/onsi/ginkgo"
     9  	. "github.com/onsi/gomega"
    10  	. "github.com/onsi/gomega/gbytes"
    11  	. "github.com/onsi/gomega/gexec"
    12  )
    13  
    14  var _ = Describe("show-missing-strings -d dirName", func() {
    15  	var (
    16  		fixturesPath   string
    17  		inputFilesPath string
    18  		session        *Session
    19  	)
    20  
    21  	BeforeEach(func() {
    22  		_, err := os.Getwd()
    23  		Ω(err).ShouldNot(HaveOccurred())
    24  
    25  		fixturesPath = filepath.Join("..", "..", "test_fixtures", "show_missing_strings")
    26  		inputFilesPath = filepath.Join(fixturesPath, "d_option", "input_files")
    27  	})
    28  
    29  	Context("When all the translated strings are in the json resource", func() {
    30  		BeforeEach(func() {
    31  			languageFilePath := filepath.Join(inputFilesPath, "no_missing_strings", "app.go.en.json")
    32  			codeDirPath := filepath.Join(inputFilesPath, "no_missing_strings", "code")
    33  			session = Runi18n("-c", "show-missing-strings", "-d", codeDirPath, "--i18n-strings-filename", languageFilePath)
    34  
    35  			Eventually(session.ExitCode()).Should(Equal(0))
    36  		})
    37  
    38  		It("Should output nothing", func() {
    39  			Ω(session).Should(Say(""))
    40  		})
    41  	})
    42  
    43  	Context("When there are strings missing from the json resource", func() {
    44  		BeforeEach(func() {
    45  			languageFilePath := filepath.Join(inputFilesPath, "missing_strings", "app.go.en.json")
    46  			codeDirPath := filepath.Join(inputFilesPath, "missing_strings", "code")
    47  			session = Runi18n("-c", "show-missing-strings", "-d", codeDirPath, "--i18n-strings-filename", languageFilePath)
    48  
    49  			Eventually(session.ExitCode()).Should(Equal(1))
    50  		})
    51  
    52  		It("Should output something", func() {
    53  			Ω(session).Should(Say("Missing"))
    54  		})
    55  	})
    56  
    57  	Context("When there are extra strings in the resource file", func() {
    58  		BeforeEach(func() {
    59  			languageFilePath := filepath.Join(inputFilesPath, "extra_strings", "app.go.en.json")
    60  			codeDirPath := filepath.Join(inputFilesPath, "extra_strings", "code")
    61  			session = Runi18n("-c", "show-missing-strings", "-d", codeDirPath, "--i18n-strings-filename", languageFilePath)
    62  
    63  			Eventually(session.ExitCode()).Should(Equal(1))
    64  		})
    65  
    66  		It("Should output something", func() {
    67  			Ω(session).Should(Say("Additional"))
    68  		})
    69  	})
    70  })