You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
memos/internal/profile/profile_test.go

25 lines
629 B
Go

package profile
import "testing"
func TestAllowAnonymous(t *testing.T) {
cases := []struct {
name string
url string
want bool
}{
{"empty is private", "", false},
{"whitespace only is private", " ", false},
{"configured url is public", "https://memos.example.com", true},
{"configured url with padding is public", " https://memos.example.com ", true},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
p := &Profile{InstanceURL: c.url}
if got := p.AllowAnonymous(); got != c.want {
t.Fatalf("AllowAnonymous() with InstanceURL=%q = %v, want %v", c.url, got, c.want)
}
})
}
}