MCPcopy
hub / github.com/garethgeorge/backrest / createSystemUnderTest

Function createSystemUnderTest

internal/api/backresthandler_test.go:1060–1114  ·  view source on GitHub ↗
(t *testing.T, config *config.ConfigManager)

Source from the content-addressed store, hash-verified

1058}
1059
1060func createSystemUnderTest(t *testing.T, config *config.ConfigManager) systemUnderTest {
1061 dir := t.TempDir()
1062
1063 cfg, err := config.Get()
1064 if err != nil {
1065 t.Fatalf("Failed to get config: %v", err)
1066 }
1067 peerStateManager := syncapi.NewInMemoryPeerStateManager()
1068 resticBin, err := resticinstaller.FindOrInstallResticBinary()
1069 if err != nil {
1070 t.Fatalf("Failed to find or install restic binary: %v", err)
1071 }
1072 opstore, err := sqlitestore.NewSqliteStore(filepath.Join(dir, "oplog.sqlite"))
1073 if err != nil {
1074 t.Fatalf("Failed to create opstore: %v", err)
1075 }
1076 t.Cleanup(func() { opstore.Close() })
1077 oplog, err := oplog.NewOpLog(opstore)
1078 if err != nil {
1079 t.Fatalf("Failed to create oplog: %v", err)
1080 }
1081 logStore, err := logstore.NewLogStore(filepath.Join(dir, "tasklogs"))
1082 if err != nil {
1083 t.Fatalf("Failed to create log store: %v", err)
1084 }
1085 t.Cleanup(func() { logStore.Close() })
1086 orch, err := orchestrator.NewOrchestrator(
1087 resticBin, config, oplog, logStore,
1088 )
1089 if err != nil {
1090 t.Fatalf("Failed to create orchestrator: %v", err)
1091 }
1092
1093 for _, repo := range cfg.Repos {
1094 rorch, err := orch.GetRepoOrchestrator(repo.Id)
1095 if err != nil {
1096 t.Fatalf("Failed to get repo %s: %v", repo.Id, err)
1097 }
1098
1099 if err := rorch.Init(context.Background()); err != nil {
1100 t.Fatalf("Failed to init repo %s: %v", repo.Id, err)
1101 }
1102 }
1103
1104 h := NewBackrestHandler(config, peerStateManager, orch, oplog, logStore)
1105
1106 return systemUnderTest{
1107 handler: h,
1108 oplog: oplog,
1109 opstore: opstore,
1110 orch: orch,
1111 logStore: logStore,
1112 config: cfg,
1113 }
1114}
1115
1116func getOperations(t *testing.T, log *oplog.OpLog) []*v1.Operation {
1117 operations := []*v1.Operation{}

Callers 10

TestUpdateConfigFunction · 0.85
TestRemoveRepoFunction · 0.85
TestBackupFunction · 0.85
TestMultipleBackupFunction · 0.85
TestHookExecutionFunction · 0.85
TestHookOnErrorHandlingFunction · 0.85
TestCancelBackupFunction · 0.85
TestRestoreFunction · 0.85
TestRunCommandFunction · 0.85

Calls 11

CloseMethod · 0.95
CloseMethod · 0.95
GetRepoOrchestratorMethod · 0.95
NewSqliteStoreFunction · 0.92
NewLogStoreFunction · 0.92
NewOrchestratorFunction · 0.92
NewBackrestHandlerFunction · 0.70
GetMethod · 0.65
InitMethod · 0.45

Tested by

no test coverage detected