33 lines
809 B
Go
33 lines
809 B
Go
package config
|
|
|
|
import "testing"
|
|
|
|
func TestValidate_Defaults(t *testing.T) {
|
|
c := &Config{
|
|
Domain: "azzamo.net",
|
|
Port: 8080,
|
|
AdminAPIKey: "long-secret-key-for-tests",
|
|
DatabasePath: ".data/nip05.db",
|
|
}
|
|
if err := Validate(c); err != nil {
|
|
t.Fatalf("expected ok, got %v", err)
|
|
}
|
|
}
|
|
|
|
func TestValidate_MissingDomain(t *testing.T) {
|
|
c := &Config{Port: 8080, AdminAPIKey: "long", DatabasePath: ".data/nip05.db"}
|
|
if err := Validate(c); err == nil {
|
|
t.Fatal("expected error")
|
|
}
|
|
}
|
|
|
|
func TestValidate_LightningRequiresLNbits(t *testing.T) {
|
|
c := &Config{
|
|
Domain: "azzamo.net", Port: 8080, AdminAPIKey: "long", DatabasePath: ".data/nip05.db",
|
|
Lightning: LightningConfig{Enabled: true},
|
|
}
|
|
if err := Validate(c); err == nil {
|
|
t.Fatal("expected error for missing LNBITS_URL")
|
|
}
|
|
}
|