package main import ( "os" "strings" "testing" ) func TestParseQuotas(t *testing.T) { f, err := os.Open("testdata/quotas.cf") if err != nil { t.Fatal(err) } defer f.Close() quotas, err := parseQuotas(f) if err != nil { t.Fatal(err) } if len(quotas) != 2 { t.Fatalf("got %d quotas, want 2", len(quotas)) } if quotas["info@produktor.io"] != "500M" { t.Errorf("info quota = %q, want 500M", quotas["info@produktor.io"]) } if quotas["ano@produktor.io"] != "250M" { t.Errorf("ano quota = %q, want 250M", quotas["ano@produktor.io"]) } } func TestParseQuotasEmpty(t *testing.T) { quotas, err := parseQuotas(strings.NewReader("# no limits\n\n")) if err != nil { t.Fatal(err) } if len(quotas) != 0 { t.Fatalf("got %d quotas, want 0", len(quotas)) } }