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

Function TestSQLiteConfig

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

Source from the content-addressed store, hash-verified

416}
417
418func TestSQLiteConfig(t *testing.T) {
419 dir, err := os.MkdirTemp("", "garm-config-test")
420 if err != nil {
421 t.Fatalf("failed to create temporary directory: %s", err)
422 }
423 t.Cleanup(func() { os.RemoveAll(dir) })
424
425 tests := []struct {
426 name string
427 cfg SQLite
428 errString string
429 }{
430 {
431 name: "Config is valid",
432 cfg: SQLite{
433 DBFile: filepath.Join(dir, "garm.db"),
434 },
435 errString: "",
436 },
437 {
438 name: "db_file is empty",
439 cfg: SQLite{
440 DBFile: "",
441 },
442 errString: "no valid db_file was specified",
443 },
444 {
445 name: "db_file must not be a relative path",
446 cfg: SQLite{
447 DBFile: "../test.db",
448 },
449 errString: "please specify an absolute path for db_file",
450 },
451 {
452 name: "parent folder must exist",
453 cfg: SQLite{
454 DBFile: "/i/dont/exist/test.db",
455 },
456 errString: "parent directory of db_file does not exist: stat.*",
457 },
458 }
459
460 for _, tc := range tests {
461 t.Run(tc.name, func(t *testing.T) {
462 err := tc.cfg.Validate()
463 if tc.errString == "" {
464 require.Nil(t, err)
465 } else {
466 require.NotNil(t, err)
467 require.Regexp(t, tc.errString, err.Error())
468 }
469 })
470 }
471}
472
473func TestJWTAuthConfig(t *testing.T) {
474 cfg := JWTAuth{

Callers

nothing calls this directly

Calls 3

RunMethod · 0.45
ValidateMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected