package geoip_test import ( "testing" "code.nonshy.com/nonshy/website/pkg/geoip" ) func TestCountryFlags(t *testing.T) { table := []struct { input string expect string err bool }{ {"US", "πŸ‡ΊπŸ‡Έ", false}, {"CA", "πŸ‡¨πŸ‡¦", false}, {"AU", "πŸ‡¦πŸ‡Ί", false}, {"NZ", "πŸ‡³πŸ‡Ώ", false}, {"CN", "πŸ‡¨πŸ‡³", false}, {"invalid", "", true}, } for _, test := range table { emoji, err := geoip.CountryFlagEmoji(test.input) if err != nil && !test.err { t.Errorf("Country %s: got an error but did not expect to: %s", test.input, err) continue } if emoji != test.expect { t.Errorf("Country %s: did not get expected emoji %s, got %+v", test.input, test.expect, emoji) } } }