cmd/gitbayd/testconfig_test.go

ff759b53942049b2043e132f5482b442a7265b98
gitbay/cmd/gitbayd/testconfig_test.go history · blame · raw

24 lines · 563 bytes

 1package main
 2
 3import (
 4	"path/filepath"
 5	"testing"
 6
 7	"gitbay.org/gitbay/internal/config"
 8	"gitbay.org/gitbay/internal/seal"
 9)
10
11// testConfig is a config with a fresh root and a key file outside it,
12// the minimum openStore accepts.
13func testConfig(t *testing.T) config.Config {
14	t.Helper()
15	key := filepath.Join(t.TempDir(), "secret.key")
16	k, err := seal.NewKey()
17	if err != nil {
18		t.Fatal(err)
19	}
20	if err := seal.WriteKeys(key, []seal.Key{k}); err != nil {
21		t.Fatal(err)
22	}
23	return config.Config{Server: config.Server{Root: t.TempDir(), SecretKeyFile: key}}
24}