github.com/coveo/gotemplate@v2.7.7+incompatible/utils/lorem_test.go (about) 1 package utils 2 3 import ( 4 "testing" 5 ) 6 7 func TestLorem(t *testing.T) { 8 tests := []struct { 9 name string 10 want string 11 wantErr bool 12 }{ 13 // WARNING: If you add tests, you must add them after those that are already there, otherwise, all results will be changed. 14 {"Word", "expedita", false}, 15 {"1", "hac", false}, 16 {"Sentence", "Laudes en sequatur aer deo vos.", false}, 17 {"Url", "http://www.dicamfactis.net/integer", false}, 18 {"EMail", "dicentium@montiumita.org", false}, 19 {"Anything", "", true}, 20 } 21 for _, tt := range tests { 22 t.Run(tt.name, func(t *testing.T) { 23 kind, _ := GetLoremKind(tt.name) 24 got, err := Lorem(kind) 25 if (err != nil) != tt.wantErr { 26 t.Errorf("Lorem() error = %v, wantErr %v", err, tt.wantErr) 27 return 28 } 29 if got != tt.want { 30 t.Errorf("Lorem() = %v, want %v", got, tt.want) 31 } 32 }) 33 } 34 }