@@ -23,8 +23,6 @@ import (
23
23
"path/filepath"
24
24
"reflect"
25
25
"testing"
26
-
27
- "github.com/google/go-cmp/cmp"
28
26
)
29
27
30
28
func TestExtract (t * testing.T ) {
@@ -81,70 +79,3 @@ func TestExtract(t *testing.T) {
81
79
}
82
80
83
81
}
84
-
85
- func TestTranslationsUpToDate (t * testing.T ) {
86
- // Move the working dir to where we would run `make extract` from
87
- cwd , err := os .Getwd ()
88
- if err != nil {
89
- t .Fatalf ("Getting current working dir: %v" , err )
90
- }
91
-
92
- err = os .Chdir ("../../.." )
93
- if err != nil {
94
- t .Fatalf ("Chdir failed: %v" , err )
95
- }
96
- defer func () {
97
- if err = os .Chdir (cwd ); err != nil {
98
- t .Logf ("Chdir to cwd failed: %v" , err )
99
- }
100
- }()
101
-
102
- // The translation file we're going to check
103
- exampleFile := "translations/fr-FR.json"
104
- src , err := ioutil .ReadFile (exampleFile )
105
- if err != nil {
106
- t .Fatalf ("Reading json file: %v" , err )
107
- }
108
-
109
- // Create a temp file to run the extractor on
110
- tempdir , err := ioutil .TempDir ("" , "temptestdata" )
111
- if err != nil {
112
- t .Fatalf ("Creating temp dir: %v" , err )
113
- }
114
- defer os .RemoveAll (tempdir )
115
-
116
- tempfile := filepath .Join (tempdir , "tmpdata.json" )
117
- err = ioutil .WriteFile (tempfile , src , 0666 )
118
- if err != nil {
119
- t .Fatalf ("Writing temp json file: %v" , err )
120
- }
121
-
122
- // Run the extractor exactly how `make extract` would run, but on the temp file
123
- err = TranslatableStrings ([]string {"cmd" , "pkg" }, []string {"translate.T" }, tempdir )
124
- if err != nil {
125
- t .Fatalf ("Error translating strings: %v" , err )
126
- }
127
-
128
- dest , err := ioutil .ReadFile (tempfile )
129
- if err != nil {
130
- t .Fatalf ("Reading resulting json file: %v" , err )
131
- }
132
-
133
- var got map [string ]interface {}
134
- var want map [string ]interface {}
135
-
136
- err = json .Unmarshal (dest , & got )
137
- if err != nil {
138
- t .Fatalf ("Populating resulting json: %v" , err )
139
- }
140
-
141
- err = json .Unmarshal (src , & want )
142
- if err != nil {
143
- t .Fatalf ("Populating original json: %v" , err )
144
- }
145
-
146
- if diff := cmp .Diff (want , got ); diff != "" {
147
- t .Fatalf ("Localized string mismatch (-want, +got):\n %s\n \n Run `make extract` to fix." , diff )
148
- }
149
-
150
- }
0 commit comments