software steht so weit.
jetzt build + docker build und testen
This commit is contained in:
1 parent
42f0c0accb
commit
ca6cdcca63
90 files changed
+10298
-480
No files matched your search
@@ -0,0 +1,44 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSettings(t *testing.T) {
|
||||
s, _ := openTest(t)
|
||||
if _, err := s.Setting(ctx, "public_url"); !errors.Is(err, ErrNotFound) {
|
||||
t.Errorf("fehlende Einstellung: erwartet ErrNotFound, bekommen %v", err)
|
||||
}
|
||||
if err := s.SetSetting(ctx, "public_url", "https://a.example:8443"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := s.SetSetting(ctx, "public_url", "https://b.example:8443"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if v, err := s.Setting(ctx, "public_url"); err != nil || v != "https://b.example:8443" {
|
||||
t.Errorf("Setting = %q, %v", v, err)
|
||||
}
|
||||
if err := s.SetSetting(ctx, "", "x"); !errors.Is(err, ErrInvalid) {
|
||||
t.Errorf("leerer Schlüssel: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSettings_SurviveReopen(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "sultan.db")
|
||||
s, err := Open(ctx, path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
s.SetSetting(ctx, "public_url", "https://a.example:8443")
|
||||
s.Close()
|
||||
s, _ = Open(ctx, path)
|
||||
defer s.Close()
|
||||
if v, _ := s.Setting(ctx, "public_url"); v != "https://a.example:8443" {
|
||||
t.Errorf("nach Neustart: %q", v)
|
||||
}
|
||||
if v, _ := s.SchemaVersion(ctx); v < 2 {
|
||||
t.Errorf("Schema-Version %d, erwartet mindestens 2", v)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user