Add struct tags flag

This commit is contained in:
Patrick O'brien 2016-09-04 23:44:54 +10:00
parent e35ecd76c1
commit 4e8191b8dd
7 changed files with 116 additions and 10 deletions

View file

@ -426,3 +426,41 @@ func TestContainsAny(t *testing.T) {
t.Errorf("Should not return true")
}
}
func TestGenerateTags(t *testing.T) {
tags := GenerateTags([]string{}, "col_name")
if tags != "" {
t.Errorf("Expected empty string, got %s", tags)
}
tags = GenerateTags([]string{"xml"}, "col_name")
exp := `xml:"col_name" `
if tags != exp {
t.Errorf("expected %s, got %s", exp, tags)
}
tags = GenerateTags([]string{"xml", "db"}, "col_name")
exp = `xml:"col_name" db:"col_name" `
if tags != exp {
t.Errorf("expected %s, got %s", exp, tags)
}
}
func TestGenerateIgnoreTags(t *testing.T) {
tags := GenerateIgnoreTags([]string{})
if tags != "" {
t.Errorf("Expected empty string, got %s", tags)
}
tags = GenerateIgnoreTags([]string{"xml"})
exp := `xml:"-" `
if tags != exp {
t.Errorf("expected %s, got %s", exp, tags)
}
tags = GenerateIgnoreTags([]string{"xml", "db"})
exp = `xml:"-" db:"-" `
if tags != exp {
t.Errorf("expected %s, got %s", exp, tags)
}
}