mirror of
https://github.com/restic/restic.git
synced 2025-10-19 07:33:21 +00:00

Rough steps: ``` mv cmd/restic/global* cmd/restic/secondary_repo* internal/global/ sed -i "s/package main/package global/" internal/global/*.go Rename "GlobalOptions" to "Options" in internal/global/ Replace everywhere " GlobalOptions" -> " global.Options" Replace everywhere "\*GlobalOptions" -> " *global.Options" Make SecondaryRepoOptions public Make create public Make version public ```
33 lines
823 B
Go
33 lines
823 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"github.com/restic/restic/internal/global"
|
|
"github.com/restic/restic/internal/restic"
|
|
rtest "github.com/restic/restic/internal/test"
|
|
)
|
|
|
|
func testRunSnapshots(t testing.TB, gopts global.Options) (newest *Snapshot, snapmap map[restic.ID]Snapshot) {
|
|
buf, err := withCaptureStdout(t, gopts, func(ctx context.Context, gopts global.Options) error {
|
|
gopts.JSON = true
|
|
|
|
opts := SnapshotOptions{}
|
|
return runSnapshots(ctx, opts, gopts, []string{}, gopts.Term)
|
|
})
|
|
rtest.OK(t, err)
|
|
|
|
snapshots := []Snapshot{}
|
|
rtest.OK(t, json.Unmarshal(buf.Bytes(), &snapshots))
|
|
|
|
snapmap = make(map[restic.ID]Snapshot, len(snapshots))
|
|
for _, sn := range snapshots {
|
|
snapmap[*sn.ID] = sn
|
|
if newest == nil || sn.Time.After(newest.Time) {
|
|
newest = &sn
|
|
}
|
|
}
|
|
return
|
|
}
|