MCPcopy Create free account
hub / github.com/cloudbase/garm / TestDatabaseConfig

Function TestDatabaseConfig

config/config_test.go:282–387  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

280}
281
282func TestDatabaseConfig(t *testing.T) {
283 dir, err := os.MkdirTemp("", "garm-config-test")
284 if err != nil {
285 t.Fatalf("failed to create temporary directory: %s", err)
286 }
287 t.Cleanup(func() { os.RemoveAll(dir) })
288 cfg := getDefaultDatabaseConfig(dir)
289
290 tests := []struct {
291 name string
292 cfg Database
293 errString string
294 }{
295 {
296 name: "Config is valid",
297 cfg: cfg,
298 errString: "",
299 },
300 {
301 name: "Missing backend",
302 cfg: Database{
303 DbBackend: "",
304 SQLite: cfg.SQLite,
305 Passphrase: cfg.Passphrase,
306 },
307 errString: "invalid databse configuration: backend is required",
308 },
309 {
310 name: "Invalid backend type",
311 cfg: Database{
312 DbBackend: DBBackendType("bogus"),
313 SQLite: cfg.SQLite,
314 Passphrase: cfg.Passphrase,
315 },
316 errString: "invalid database backend: bogus",
317 },
318 {
319 name: "Missing passphrase",
320 cfg: Database{
321 DbBackend: cfg.DbBackend,
322 SQLite: cfg.SQLite,
323 Passphrase: "",
324 },
325 errString: "passphrase must be set and it must be a string of 32 characters*",
326 },
327 {
328 name: "passphrase has invalid length",
329 cfg: Database{
330 DbBackend: cfg.DbBackend,
331 SQLite: cfg.SQLite,
332 Passphrase: "testing",
333 },
334 errString: "passphrase must be set and it must be a string of 32 characters*",
335 },
336 {
337 name: "passphrase is too weak",
338 cfg: Database{
339 DbBackend: cfg.DbBackend,

Callers

nothing calls this directly

Calls 6

getDefaultDatabaseConfigFunction · 0.85
DBBackendTypeTypeAlias · 0.85
getMySQLDefaultConfigFunction · 0.85
RunMethod · 0.45
ValidateMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected