diff options
author | Nick Snyder <nickdsnyder@gmail.com> | 2019-05-06 22:53:11 +0300 |
---|---|---|
committer | Nick Snyder <nickdsnyder@gmail.com> | 2019-05-06 22:53:11 +0300 |
commit | 70cf5c13667144b18b4dfc835510b9417137a67b (patch) | |
tree | 2b659e2a83fda8064f52166fc042a9ffed0c6e2f | |
parent | a3498dc6b5acdb35db3ff95da521011aeda30d80 (diff) |
cleanup
-rw-r--r-- | i18n/translation/template_test.go | 63 | ||||
-rw-r--r-- | i18n/translation/translation_test.go | 2 | ||||
-rw-r--r-- | v2/goi18n/extract_command.go | 5 |
3 files changed, 3 insertions, 67 deletions
diff --git a/i18n/translation/template_test.go b/i18n/translation/template_test.go index 71438b6..a28c3ed 100644 --- a/i18n/translation/template_test.go +++ b/i18n/translation/template_test.go @@ -3,7 +3,7 @@ package translation import ( "bytes" "fmt" - //"launchpad.net/goyaml" + "testing" gotemplate "text/template" ) @@ -32,67 +32,9 @@ func TestMarshalText(t *testing.T) { func TestUnmarshalText(t *testing.T) { tmpl := &template{} - tmpl.UnmarshalText([]byte("hello {{.World}}")) - result := tmpl.Execute(map[string]string{ - "World": "world!", - }) - expected := "hello world!" - if result != expected { - t.Errorf("expected %#v; got %#v", expected, result) - } -} - -/* -func TestYAMLMarshal(t *testing.T) { - src := "hello {{.World}}" - tmpl, err := newTemplate(src) - if err != nil { - t.Fatal(err) - } - buf, err := goyaml.Marshal(tmpl) - if err != nil { + if err := tmpl.UnmarshalText([]byte("hello {{.World}}")); err != nil { t.Fatal(err) } - if !bytes.Equal(buf, []byte(src)) { - t.Fatalf(`expected "%s"; got "%s"`, src, buf) - } -} - -func TestYAMLUnmarshal(t *testing.T) { - buf := []byte(`Tmpl: "hello"`) - - var out struct { - Tmpl *template - } - var foo map[string]string - if err := goyaml.Unmarshal(buf, &foo); err != nil { - t.Fatal(err) - } - if out.Tmpl == nil { - t.Fatalf("out.Tmpl was nil") - } - if out.Tmpl.tmpl == nil { - t.Fatalf("out.Tmpl.tmpl was nil") - } - if expected := "hello {{.World}}"; out.Tmpl.src != expected { - t.Fatalf("expected %s; got %s", expected, out.Tmpl.src) - } -} - -func TestGetYAML(t *testing.T) { - src := "hello" - tmpl := &template{ - tmpl: nil, - src: src, - } - if tag, value := tmpl.GetYAML(); tag != "" || value != src { - t.Errorf("GetYAML() returned (%#v, %#v); expected (%#v, %#v)", tag, value, "", src) - } -} - -func TestSetYAML(t *testing.T) { - tmpl := &template{} - tmpl.SetYAML("tagDoesntMatter", "hello {{.World}}") result := tmpl.Execute(map[string]string{ "World": "world!", }) @@ -101,7 +43,6 @@ func TestSetYAML(t *testing.T) { t.Errorf("expected %#v; got %#v", expected, result) } } -*/ func BenchmarkExecuteNilTemplate(b *testing.B) { template := &template{src: "hello world"} diff --git a/i18n/translation/translation_test.go b/i18n/translation/translation_test.go index 7380d5a..4740e02 100644 --- a/i18n/translation/translation_test.go +++ b/i18n/translation/translation_test.go @@ -6,7 +6,7 @@ import ( ) // Check this here to avoid unnecessary import of sort package. -var _ = sort.Interface(make(SortableByID, 0, 0)) +var _ = sort.Interface(make(SortableByID, 0)) func TestNewSingleTranslation(t *testing.T) { t.Skipf("not implemented") diff --git a/v2/goi18n/extract_command.go b/v2/goi18n/extract_command.go index cd01e72..87debbb 100644 --- a/v2/goi18n/extract_command.go +++ b/v2/goi18n/extract_command.go @@ -132,11 +132,6 @@ func newExtractor(file *ast.File) *extractor { type extractor struct { i18nPackageName string messages []*i18n.Message - errs []error -} - -func (e *extractor) err(err error) { - e.errs = append(e.errs, err) } func (e *extractor) Visit(node ast.Node) ast.Visitor { |