github.com/CharukaK/i18n4go@v0.6.0/integration/verify_strings/duplicate_keys_test.go (about)

     1  // Copyright © 2015-2023 The Knative Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package verify_strings_test
    16  
    17  import (
    18  	"os"
    19  	"path/filepath"
    20  
    21  	. "github.com/CharukaK/i18n4go/integration/test_helpers"
    22  	. "github.com/onsi/ginkgo"
    23  	. "github.com/onsi/gomega"
    24  	"github.com/onsi/gomega/gbytes"
    25  )
    26  
    27  var _ = Describe("verify-strings -f fileName", func() {
    28  	var (
    29  		fixturesPath      string
    30  		inputFilesPath    string
    31  		expectedFilesPath string
    32  	)
    33  
    34  	BeforeEach(func() {
    35  		_, err := os.Getwd()
    36  		Ω(err).ShouldNot(HaveOccurred())
    37  
    38  		Ω(err).ToNot(HaveOccurred())
    39  
    40  		fixturesPath = filepath.Join("..", "..", "test_fixtures", "verify_strings")
    41  		inputFilesPath = filepath.Join(fixturesPath, "duplicate_keys", "input_files")
    42  		expectedFilesPath = filepath.Join(fixturesPath, "duplicate_keys", "expected_output")
    43  	})
    44  	Context("Using legacy commands", func() {
    45  		Context("checks for duplicate keys", func() {
    46  			It("should error", func() {
    47  				session := Runi18n("-c", "verify-strings", "-v", "-f", filepath.Join(inputFilesPath, "quota.go.en.json"), "--languages", "\"fr\"", "-o", expectedFilesPath, "--source-language", "en")
    48  				Ω(session.ExitCode()).Should(Equal(1))
    49  				Ω(session).Should(gbytes.Say("Duplicated key found: Show quota info"))
    50  			})
    51  		})
    52  	})
    53  
    54  	Context("Using cobra commands", func() {
    55  		Context("checks for duplicate keys", func() {
    56  			It("should error", func() {
    57  				session := Runi18n("verify-strings", "-v", "-f", filepath.Join(inputFilesPath, "quota.go.en.json"), "--languages", "\"fr\"", "-o", expectedFilesPath, "--source-language", "en")
    58  				Ω(session.ExitCode()).Should(Equal(1))
    59  				Ω(session).Should(gbytes.Say("Duplicated key found: Show quota info"))
    60  			})
    61  		})
    62  	})
    63  
    64  })