package tenant import "testing" func TestValidateSlug(t *testing.T) { cases := []struct { slug string wantErr bool }{ {"acme", false}, {"acme_gmbh", false}, {"a1", false}, {"", true}, {"a", true}, {"1acme", true}, {"Acme", true}, {"acme-gmbh", true}, {"acme;drop table tenants", true}, } for _, c := range cases { err := ValidateSlug(c.slug) if (err != nil) != c.wantErr { t.Errorf("ValidateSlug(%q) error = %v, wantErr %v", c.slug, err, c.wantErr) } } } func TestDBNameForSlug(t *testing.T) { got := dbNameForSlug("acme") want := "tenant_acme" if got != want { t.Errorf("dbNameForSlug() = %q, want %q", got, want) } }